mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-23 13:23:33 +03:00
Add --show-domain flag to list short URLs command
This commit is contained in:
parent
f2ecbceae9
commit
cf49393ef2
2 changed files with 35 additions and 4 deletions
|
@ -102,6 +102,12 @@ class ListShortUrlsCommand extends Command
|
|||
InputOption::VALUE_NONE,
|
||||
'Whether to display the tags or not.',
|
||||
)
|
||||
->addOption(
|
||||
'show-domain',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Whether to display the domain or not. Those belonging to default domain will have value "DEFAULT".',
|
||||
)
|
||||
->addOption(
|
||||
'show-api-key',
|
||||
'k',
|
||||
|
@ -217,6 +223,10 @@ class ListShortUrlsCommand extends Command
|
|||
if ($input->getOption('show-tags')) {
|
||||
$columnsMap['Tags'] = static fn (array $shortUrl): string => implode(', ', $shortUrl['tags']);
|
||||
}
|
||||
if ($input->getOption('show-domain')) {
|
||||
$columnsMap['Domain'] = static fn (array $_, ShortUrl $shortUrl): string =>
|
||||
$shortUrl->getDomain()?->authority ?? 'DEFAULT';
|
||||
}
|
||||
if ($input->getOption('show-api-key')) {
|
||||
$columnsMap['API Key'] = static fn (array $_, ShortUrl $shortUrl): string =>
|
||||
$shortUrl->authorApiKey()?->__toString() ?? '';
|
||||
|
|
|
@ -144,13 +144,19 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
yield 'tags only' => [
|
||||
['--show-tags' => true],
|
||||
['| Tags ', '| foo, bar, baz'],
|
||||
['| API Key ', '| API Key Name |', $key, '| my api key'],
|
||||
['| API Key ', '| API Key Name |', $key, '| my api key', '| Domain', '| DEFAULT'],
|
||||
$apiKey,
|
||||
];
|
||||
yield 'domain only' => [
|
||||
['--show-domain' => true],
|
||||
['| Domain', '| DEFAULT'],
|
||||
['| Tags ', '| foo, bar, baz', '| API Key ', '| API Key Name |', $key, '| my api key'],
|
||||
$apiKey,
|
||||
];
|
||||
yield 'api key only' => [
|
||||
['--show-api-key' => true],
|
||||
['| API Key ', $key],
|
||||
['| Tags ', '| foo, bar, baz', '| API Key Name |', '| my api key'],
|
||||
['| Tags ', '| foo, bar, baz', '| API Key Name |', '| my api key', '| Domain', '| DEFAULT'],
|
||||
$apiKey,
|
||||
];
|
||||
yield 'api key name only' => [
|
||||
|
@ -165,9 +171,24 @@ class ListShortUrlsCommandTest extends TestCase
|
|||
['| API Key Name |', '| my api key'],
|
||||
$apiKey,
|
||||
];
|
||||
yield 'tags and domain' => [
|
||||
['--show-tags' => true, '--show-domain' => true],
|
||||
['| Tags ', '| foo, bar, baz', '| Domain', '| DEFAULT'],
|
||||
['| API Key Name |', '| my api key'],
|
||||
$apiKey,
|
||||
];
|
||||
yield 'all' => [
|
||||
['--show-tags' => true, '--show-api-key' => true, '--show-api-key-name' => true],
|
||||
['| API Key ', '| Tags ', '| API Key Name |', '| foo, bar, baz', $key, '| my api key'],
|
||||
['--show-tags' => true, '--show-domain' => true, '--show-api-key' => true, '--show-api-key-name' => true],
|
||||
[
|
||||
'| API Key ',
|
||||
'| Tags ',
|
||||
'| API Key Name |',
|
||||
'| foo, bar, baz',
|
||||
$key,
|
||||
'| my api key',
|
||||
'| Domain',
|
||||
'| DEFAULT',
|
||||
],
|
||||
[],
|
||||
$apiKey,
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue