diff --git a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php index 9fd39d44..34ccd57f 100644 --- a/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php +++ b/module/CLI/src/Command/ShortUrl/ListShortUrlsCommand.php @@ -65,6 +65,12 @@ class ListShortUrlsCommand extends Command InputOption::VALUE_REQUIRED, 'A query used to filter results by searching for it on the longUrl and shortCode fields.', ) + ->addOption( + 'domain', + 'd', + InputOption::VALUE_REQUIRED, + 'Used to filter results by domain. Use DEFAULT keyword to filter by default domain', + ) ->addOption( 'tags', 't', @@ -135,6 +141,7 @@ class ListShortUrlsCommand extends Command $page = (int) $input->getOption('page'); $searchTerm = $input->getOption('search-term'); + $domain = $input->getOption('domain'); $tags = $input->getOption('tags'); $tagsMode = $input->getOption('including-all-tags') === true ? TagsMode::ALL->value : TagsMode::ANY->value; $tags = ! empty($tags) ? explode(',', $tags) : []; @@ -146,6 +153,7 @@ class ListShortUrlsCommand extends Command $data = [ ShortUrlsParamsInputFilter::SEARCH_TERM => $searchTerm, + ShortUrlsParamsInputFilter::DOMAIN => $domain, ShortUrlsParamsInputFilter::TAGS => $tags, ShortUrlsParamsInputFilter::TAGS_MODE => $tagsMode, ShortUrlsParamsInputFilter::ORDER_BY => $orderBy, diff --git a/module/CLI/test-cli/Command/ListShortUrlsTest.php b/module/CLI/test-cli/Command/ListShortUrlsTest.php index 8d9c7278..d7c50912 100644 --- a/module/CLI/test-cli/Command/ListShortUrlsTest.php +++ b/module/CLI/test-cli/Command/ListShortUrlsTest.php @@ -70,6 +70,23 @@ class ListShortUrlsTest extends CliTestCase | custom-with-domain | | http://some-domain.com/custom-with-domain | https://google.com | 2018-10-20T00:00:00+00:00 | 0 | +--------------------+-------+-------------------------------------------+-------------------------------- Page 1 of 1 --------------------------------------------------------------+---------------------------+--------------+ OUTPUT]; + yield 'non-default domain' => [['--domain=example.com'], << [['-d DEFAULT'], <<