improve the command

This commit is contained in:
Simon Vieille 2019-04-25 12:42:23 +02:00
parent bdb92142d9
commit f32fdcdcc5
Signed by: deblan
GPG Key ID: 03383D15A1D31745
2 changed files with 17 additions and 4 deletions

View File

@ -14,7 +14,7 @@ $ composer install
```
```
$ php7.3 ./domain-expiration check example.com,other-example.com
$ php7.3 ./domain-expiration check example.com other-example.com
+------------------------+---------------------+
| Domain | Date |
+------------------------+---------------------+

View File

@ -44,7 +44,13 @@ class CheckCommand extends BaseCommand
{
$this
->setName('check')
->addArgument('domains', InputArgument::REQUIRED, 'List of domains separated by commas');
->addArgument('domains', InputArgument::IS_ARRAY|InputArgument::REQUIRED, 'List of domains.')
->setHelp(<<<EOF
The <info>%command.name%</info> retrieves the expiration dates of the given domains.
Example: %command.full_name% example.com other-example.com
EOF
);
}
/**
@ -84,8 +90,15 @@ class CheckCommand extends BaseCommand
*/
protected function getDomains():array
{
$domains = explode(',', $this->input->getArgument('domains'));
$domains = array_map('trim', $domains);
$inputDomains = $this->input->getArgument('domains');
$domains = [];
foreach ($inputDomains as $inputDomain) {
$value = explode(',', $inputDomain);
$value = array_map('trim', $value);
$domains = array_merge($value, $domains);
}
return $domains;
}