From 03bdaa11f643591f19e5cd5494e6c44eaaab9c68 Mon Sep 17 00:00:00 2001 From: Craig Williams Date: Wed, 16 Mar 2022 14:44:07 +0000 Subject: [PATCH] Remove $quiet as its handled elsewhere --- src/Bakery/ScheduleCommand.php | 54 +++++++++++----------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/src/Bakery/ScheduleCommand.php b/src/Bakery/ScheduleCommand.php index 1cdbd08..3f0b5ce 100644 --- a/src/Bakery/ScheduleCommand.php +++ b/src/Bakery/ScheduleCommand.php @@ -48,43 +48,30 @@ class ScheduleCommand extends BaseCommand */ protected function execute(InputInterface $input, OutputInterface $output) { - // Get options - $quiet = $input->getOption('quiet'); - - if (!$quiet) { - $this->io->title("UserFrosting's Scheduler"); - } + $this->io->title("UserFrosting's Scheduler"); // Prepare task locator $scheduler = $this->ci->scheduler; - - if (!$quiet) { - $this->io->writeln('Checking for tasks to run...'); - } + $this->io->writeln('Checking for tasks to run...'); $tasks = []; - // Start by getting tasks + // Find which tasks are due foreach ($scheduler->getTasks() as $task) { if ($task['instance']->isDue()) { - // Add task class to list $tasks[] = $task; } } if (count($tasks) == 0) { - if (!$quiet) { - $this->io->success('Nothing to do'); - } + $this->io->success('Nothing to do'); return self::SUCCESS; } - if (!$quiet) { - $this->io->writeln('Found ' . count($tasks) . ' task(s) to run'); - $this->io->writeln(''); - $this->io->writeln('Running tasks...'); - } + $this->io->writeln('Found ' . count($tasks) . ' task(s) to run'); + $this->io->writeln(''); + $this->io->writeln('Running tasks...'); $hasFailure = false; @@ -95,20 +82,10 @@ class ScheduleCommand extends BaseCommand $start = hrtime(true); try { - - if (!($taskSuccess = $task['instance']->run())) { + if (!$task['instance']->run()) { throw new Exception('Task returned failure'); } - } catch (\Exception $e) { - $taskSuccess = false; - $hasFailure = true; - if ($quiet) { - $this->io->write('Running task `' . $task['class'] . '`...'); - } - $this->io->error(' [ERROR] ' . $e->getMessage() . ' '); - } - if (!$quiet && $taskSuccess) { $end = hrtime(true); $tdiff = round(($end-$start) / 1e+6); @@ -119,19 +96,22 @@ class ScheduleCommand extends BaseCommand } $this->io->writeln($tdiff . $tunit); + } catch (\Exception $e) { + $taskSuccess = false; + $hasFailure = true; + $this->io->writeln(' [ERROR] ' . $e->getMessage() . ' '); + } + + if ($taskSuccess) { } } // Success if (!$hasFailure) { - if (!$quiet) { - $this->io->success('Schedule success !'); - } + $this->io->success('Schedule success !'); return self::SUCCESS; } else { - if (!$quiet) { - $this->io->error('Schedule failed !'); - } + $this->io->error('Schedule failed !'); return self::FAILURE; }