mirror of
https://github.com/shlinkio/shlink.git
synced 2025-12-10 22:13:47 -06:00
Deprecate --tags and add --tag for short-url:list command
This commit is contained in:
parent
41c03a66e4
commit
25de0263c5
@ -73,6 +73,11 @@ class ListShortUrlsCommand extends Command
|
|||||||
)
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'tags',
|
'tags',
|
||||||
|
mode: InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
|
||||||
|
description: '[DEPRECATED] Use --tag instead',
|
||||||
|
)
|
||||||
|
->addOption(
|
||||||
|
'tag',
|
||||||
't',
|
't',
|
||||||
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
|
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
|
||||||
'A list of tags that short URLs need to include.',
|
'A list of tags that short URLs need to include.',
|
||||||
@ -84,7 +89,7 @@ class ListShortUrlsCommand extends Command
|
|||||||
description: 'If --tags is provided, returns only short URLs including ALL of them',
|
description: 'If --tags is provided, returns only short URLs including ALL of them',
|
||||||
)
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'exclude-tags',
|
'exclude-tag',
|
||||||
'et',
|
'et',
|
||||||
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
|
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
|
||||||
'A list of tags that short URLs should not have.',
|
'A list of tags that short URLs should not have.',
|
||||||
@ -92,7 +97,7 @@ class ListShortUrlsCommand extends Command
|
|||||||
->addOption(
|
->addOption(
|
||||||
'exclude-tags-all',
|
'exclude-tags-all',
|
||||||
mode: InputOption::VALUE_NONE,
|
mode: InputOption::VALUE_NONE,
|
||||||
description: 'If --exclude-tags is provided, returns only short URLs not including ANY of them',
|
description: 'If --exclude-tag is provided, returns only short URLs not including ANY of them',
|
||||||
)
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'exclude-max-visits-reached',
|
'exclude-max-visits-reached',
|
||||||
@ -150,13 +155,13 @@ class ListShortUrlsCommand extends Command
|
|||||||
$domain = $input->getOption('domain');
|
$domain = $input->getOption('domain');
|
||||||
|
|
||||||
// FIXME DEPRECATED Remove support for comma-separated tags in next major release
|
// FIXME DEPRECATED Remove support for comma-separated tags in next major release
|
||||||
$tags = $input->getOption('tags');
|
$tags = [...$input->getOption('tag'), ...$input->getOption('tags')];
|
||||||
$tags = flatten(map($tags, static fn (string $tag) => explode(',', $tag)));
|
$tags = flatten(map($tags, static fn (string $tag) => explode(',', $tag)));
|
||||||
$tagsMode = $input->getOption('tags-all') === true || $input->getOption('including-all-tags') === true
|
$tagsMode = $input->getOption('tags-all') === true || $input->getOption('including-all-tags') === true
|
||||||
? TagsMode::ALL->value
|
? TagsMode::ALL->value
|
||||||
: TagsMode::ANY->value;
|
: TagsMode::ANY->value;
|
||||||
|
|
||||||
$excludeTags = $input->getOption('exclude-tags');
|
$excludeTags = $input->getOption('exclude-tag');
|
||||||
$excludeTagsMode = $input->getOption('exclude-tags-all') === true ? TagsMode::ALL->value : TagsMode::ANY->value;
|
$excludeTagsMode = $input->getOption('exclude-tags-all') === true ? TagsMode::ALL->value : TagsMode::ANY->value;
|
||||||
|
|
||||||
$all = $input->getOption('all');
|
$all = $input->getOption('all');
|
||||||
|
|||||||
@ -25,8 +25,6 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
|||||||
use ShlinkioTest\Shlink\CLI\Util\CliTestUtils;
|
use ShlinkioTest\Shlink\CLI\Util\CliTestUtils;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
|
||||||
use function explode;
|
|
||||||
|
|
||||||
class ListShortUrlsCommandTest extends TestCase
|
class ListShortUrlsCommandTest extends TestCase
|
||||||
{
|
{
|
||||||
private CommandTester $commandTester;
|
private CommandTester $commandTester;
|
||||||
@ -209,6 +207,8 @@ class ListShortUrlsCommandTest extends TestCase
|
|||||||
string $tagsMode,
|
string $tagsMode,
|
||||||
string|null $startDate = null,
|
string|null $startDate = null,
|
||||||
string|null $endDate = null,
|
string|null $endDate = null,
|
||||||
|
array $excludeTags = [],
|
||||||
|
string $excludeTagsMode = TagsMode::ANY->value,
|
||||||
): void {
|
): void {
|
||||||
$this->shortUrlService->expects($this->once())->method('listShortUrls')->with(ShortUrlsParams::fromRawData([
|
$this->shortUrlService->expects($this->once())->method('listShortUrls')->with(ShortUrlsParams::fromRawData([
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
@ -217,6 +217,8 @@ class ListShortUrlsCommandTest extends TestCase
|
|||||||
'tagsMode' => $tagsMode,
|
'tagsMode' => $tagsMode,
|
||||||
'startDate' => $startDate !== null ? Chronos::parse($startDate)->toAtomString() : null,
|
'startDate' => $startDate !== null ? Chronos::parse($startDate)->toAtomString() : null,
|
||||||
'endDate' => $endDate !== null ? Chronos::parse($endDate)->toAtomString() : null,
|
'endDate' => $endDate !== null ? Chronos::parse($endDate)->toAtomString() : null,
|
||||||
|
'excludeTags' => $excludeTags,
|
||||||
|
'excludeTagsMode' => $excludeTagsMode,
|
||||||
]))->willReturn(new Paginator(new ArrayAdapter([])));
|
]))->willReturn(new Paginator(new ArrayAdapter([])));
|
||||||
|
|
||||||
$this->commandTester->setInputs(['n']);
|
$this->commandTester->setInputs(['n']);
|
||||||
@ -230,10 +232,10 @@ class ListShortUrlsCommandTest extends TestCase
|
|||||||
yield [['--including-all-tags' => true], 1, null, [], TagsMode::ALL->value];
|
yield [['--including-all-tags' => true], 1, null, [], TagsMode::ALL->value];
|
||||||
yield [['--search-term' => $searchTerm = 'search this'], 1, $searchTerm, [], TagsMode::ANY->value];
|
yield [['--search-term' => $searchTerm = 'search this'], 1, $searchTerm, [], TagsMode::ANY->value];
|
||||||
yield [
|
yield [
|
||||||
['--page' => $page = 3, '--search-term' => $searchTerm = 'search this', '--tags' => $tags = 'foo,bar'],
|
['--page' => $page = 3, '--search-term' => $searchTerm = 'search this', '--tag' => $tags = ['foo', 'bar']],
|
||||||
$page,
|
$page,
|
||||||
$searchTerm,
|
$searchTerm,
|
||||||
explode(',', $tags),
|
$tags,
|
||||||
TagsMode::ANY->value,
|
TagsMode::ANY->value,
|
||||||
];
|
];
|
||||||
yield [
|
yield [
|
||||||
@ -262,6 +264,17 @@ class ListShortUrlsCommandTest extends TestCase
|
|||||||
$startDate,
|
$startDate,
|
||||||
$endDate,
|
$endDate,
|
||||||
];
|
];
|
||||||
|
yield [
|
||||||
|
['--exclude-tag' => ['foo', 'bar'], '--exclude-tags-all' => true],
|
||||||
|
1,
|
||||||
|
null,
|
||||||
|
[],
|
||||||
|
TagsMode::ANY->value,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
['foo', 'bar'],
|
||||||
|
TagsMode::ALL->value,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test, DataProvider('provideOrderBy')]
|
#[Test, DataProvider('provideOrderBy')]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user