fix #1: add argument --wait to wait between each request
This commit is contained in:
parent
d660c94d38
commit
3165f2664c
|
@ -29,3 +29,4 @@ You are able specify output options:
|
|||
* `--short` (`-s`): removes borders
|
||||
* `--no-header`: removes headers
|
||||
* `--json` (`-j`): output is a json
|
||||
* `--wait` (`-w`) xx: wait xx seconds between each request
|
||||
|
|
|
@ -48,6 +48,7 @@ class CheckCommand extends BaseCommand
|
|||
->addArgument('domains', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'List of domains')
|
||||
->addOption('short', 's', InputOption::VALUE_NONE, 'Simplify the table output')
|
||||
->addOption('no-headers', null, InputOption::VALUE_NONE, 'Remove the table headers')
|
||||
->addOption('wait', 'w', InputOption::VALUE_REQUIRED, 'Wait between each whois')
|
||||
->addOption('json', 'j', InputOption::VALUE_NONE, 'Select json as output')
|
||||
->addOption('table', 't', InputOption::VALUE_NONE, 'Select table as output')
|
||||
->setHelp(<<<'EOF'
|
||||
|
@ -65,8 +66,9 @@ EOF
|
|||
{
|
||||
$this->input = $input;
|
||||
$this->output = $output;
|
||||
$wait = (int) $this->input->getOption('wait');
|
||||
|
||||
$this->checkDomains();
|
||||
$this->checkDomains($wait);
|
||||
|
||||
$short = $this->input->getOption('short');
|
||||
$json = $this->input->getOption('json');
|
||||
|
@ -161,9 +163,12 @@ EOF
|
|||
/**
|
||||
* Checks domains.
|
||||
*/
|
||||
protected function checkDomains():void
|
||||
protected function checkDomains(int $wait):void
|
||||
{
|
||||
foreach ($this->getDomains() as $domain) {
|
||||
$domains = $this->getDomains();
|
||||
$count = count($domains);
|
||||
|
||||
foreach ($domains as $key => $domain) {
|
||||
$data = $this->checkDomain($domain);
|
||||
|
||||
if ($data['expiryDate'] === null) {
|
||||
|
@ -171,6 +176,10 @@ EOF
|
|||
} else {
|
||||
$this->successes[] = $data;
|
||||
}
|
||||
|
||||
if ($wait > 0 && $key !== $count - 1) {
|
||||
sleep($wait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue