public function execute() { /** @var AbstractCommand[] $commandList */ $commandList = ServiceContainer::getInstance()->getListByTag('command'); echo 'Command list: ' . PHP_EOL; echo '====================' . PHP_EOL; foreach ($commandList as $command) { echo PHP_EOL . ' ' . $command->getName() . ' - ' . $command->getDescription() . PHP_EOL; $optionList = $command->getOptionList(); if ($optionList) { echo ' ' . 'Options list: ' . PHP_EOL; foreach ($optionList as $option) { $req = ConsoleOption::REQUIRED === $option->getMode() ? ' (req) ' : ''; echo ' ' . '-' . $option->getName() . $req . ' --- ' . $option->getDescription() . PHP_EOL; } } $argumentList = $command->getArgumentList(); if ($argumentList) { echo ' ' . 'Arguments list: ' . PHP_EOL; foreach ($argumentList as $argument) { $req = ConsoleOption::REQUIRED === $argument->getMode() ? ' (req) ' : ''; echo ' ' . '-' . $argument->getName() . $req . ' --- ' . $argument->getDescription() . PHP_EOL; } } } }
public function execute() { /** @var $urlProvider UrlProviderInterface */ $urlProvider = ServiceContainer::getInstance()->get('provider.url_from_file'); $urlProvider->init($this->getArgumentValue('fileName')); /** @var $botService BotService */ $botService = ServiceContainer::getInstance()->get('service.bot'); /** @var UrlProcessing[] $urlProcessingList */ $urlProcessingList = $botService->scheduler($urlProvider); /** @var ConsoleViewService $consoleViewService */ $consoleViewService = ServiceContainer::getInstance()->get('service.console_view'); $consoleViewService->showUrlProcessingReport($urlProcessingList); }
public function execute() { /** @var BotService $botService */ $botService = ServiceContainer::getInstance()->get('service.bot'); $limit = (int) $this->getOptionValue('limit'); $rewrite = $this->hasOptionValue('force'); /** @var DownloadService $downloadService */ $downloadService = ServiceContainer::getInstance()->get('service.download'); /** @var UrlProcessing[] $urlProcessingList */ $urlProcessingList = $botService->download($downloadService, $rewrite, $limit); /** @var ConsoleViewService $consoleViewService */ $consoleViewService = ServiceContainer::getInstance()->get('service.console_view'); $consoleViewService->showUrlProcessingReport($urlProcessingList); }
/** * @param $consoleArgDataList * @throws Exception */ protected function initConsoleCommand($consoleArgDataList) { if (empty($consoleArgDataList[1])) { throw new Exception('Command name is empty'); } /** @var AbstractCommand[] $commandList */ $commandList = ServiceContainer::getInstance()->getListByTag('command'); if (!$commandList) { throw new Exception('Empty command list'); } $commandName = $consoleArgDataList[1]; $command = array_filter($commandList, function ($commandInfo) use($commandName) { /** @var AbstractCommand $commandInfo */ return $commandInfo->getName() === $commandName; }); if (!$command) { throw new Exception('Command ' . $commandName . ' not found'); } if (count($command) > 1) { throw new Exception('Found more than one command with name ' . $commandName); } $this->command = current($command); }