diff --git a/src/Symfony/Component/Scheduler/Command/DebugCommand.php b/src/Symfony/Component/Scheduler/Command/DebugCommand.php index 04a2ed533f5e8..f6c19939a574f 100644 --- a/src/Symfony/Component/Scheduler/Command/DebugCommand.php +++ b/src/Symfony/Component/Scheduler/Command/DebugCommand.php @@ -27,6 +27,8 @@ * Command to list/debug schedules. * * @author Kevin Bond + * + * @experimental */ #[AsCommand(name: 'debug:scheduler', description: 'List schedules and their recurring messages')] final class DebugCommand extends Command @@ -63,16 +65,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io = new SymfonyStyle($input, $output); $io->title('Scheduler'); - $names = $input->getArgument('schedule') ?: $this->scheduleNames; + if (!$names = $input->getArgument('schedule') ?: $this->scheduleNames) { + $io->error('No schedules found.'); + + return self::FAILURE; + } foreach ($names as $name) { + $io->section($name); + /** @var ScheduleProviderInterface $schedule */ $schedule = $this->schedules->get($name); + if (!$messages = $schedule->getSchedule()->getRecurringMessages()) { + $io->warning(sprintf('No recurring messages found for schedule "%s".', $name)); - $io->section($name); + continue; + } $io->table( ['Message', 'Trigger', 'Next Run'], - array_map(self::renderRecurringMessage(...), $schedule->getSchedule()->getRecurringMessages()) + array_map(self::renderRecurringMessage(...), $messages), ); }