diff --git a/.gitignore b/.gitignore index b7c0b54..67caf54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.editorconfig /.php-cs-fixer.cache +/.phpunit.cache /.phpunit.result.cache /composer.lock /vendor diff --git a/CHANGELOG.md b/CHANGELOG.md index 01fbe6a..2d842c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +3.3.2 +===== + +* (improvement) note + + 3.3.1 ===== diff --git a/phpunit.xml b/phpunit.xml index e7c0d26..44d43b3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,24 +1,15 @@ - - - - - - - - - - - tests - tests/fixtures - - - - - - + + + + + + + + + + tests + tests/fixtures + + diff --git a/src/Command/QueueTasksCommand.php b/src/Command/QueueTasksCommand.php index e0128c4..b38fb31 100644 --- a/src/Command/QueueTasksCommand.php +++ b/src/Command/QueueTasksCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Torr\Cli\Console\Style\TorrStyle; +use Torr\Hosting\Hosting\HostingEnvironment; use Torr\TaskManager\Exception\Registry\UnknownTaskKeyException; use Torr\TaskManager\Manager\TaskManager; use Torr\TaskManager\Registry\TaskRegistry; @@ -23,6 +24,7 @@ public function __construct ( private readonly TaskRegistry $taskRegistry, private readonly TaskManager $taskManager, private readonly TransportsHelper $receiverHelper, + private readonly HostingEnvironment $hostingEnvironment, ) { parent::__construct(); @@ -53,7 +55,7 @@ protected function execute (InputInterface $input, OutputInterface $output) : in try { - $tasksToQueue = $this->getTasksToQueue($input, $io); + [$tasksToQueue, $taskPassedExplicitly] = $this->getTasksToQueue($input, $io); } catch (UnknownTaskKeyException $exception) { @@ -79,13 +81,24 @@ protected function execute (InputInterface $input, OutputInterface $output) : in $io->success("All done."); + if ($this->hostingEnvironment->isDevelopment() && !$taskPassedExplicitly && 1 === \count($tasksToQueue)) + { + $io->newLine(2); + $io->comment("If you want to easily requeue this task, you can use the direct command:"); + $io->writeln(\sprintf( + "bin/console task-manager:queue %s", + $tasksToQueue[0]->getMetaData()->getKey(), + )); + $io->newLine(); + } + return self::SUCCESS; } /** * Handles the interaction to get the tasks to queue * - * @return Task[] + * @return array{0: Task[], 1: bool} the tasks to queue and whether they were passed explicitly */ private function getTasksToQueue (InputInterface $input, TorrStyle $io) : array { @@ -94,7 +107,10 @@ private function getTasksToQueue (InputInterface $input, TorrStyle $io) : array if ([] !== $taskKeysProvidedInArgument) { - return $this->fetchTasksByKey($taskKeysProvidedInArgument); + return [ + $this->fetchTasksByKey($taskKeysProvidedInArgument), + true, + ]; } $flatTasks = []; @@ -126,7 +142,7 @@ private function getTasksToQueue (InputInterface $input, TorrStyle $io) : array $result[] = $flatTasks[$index]; } - return $result; + return [$result, false]; } /**