Remove $quiet as its handled elsewhere

This commit is contained in:
2022-03-16 14:44:07 +00:00
parent c542721982
commit 03bdaa11f6

View File

@@ -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");
}
// Prepare task locator
$scheduler = $this->ci->scheduler;
if (!$quiet) {
$this->io->writeln('<comment>Checking for tasks to run...</comment>');
}
$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');
}
return self::SUCCESS;
}
if (!$quiet) {
$this->io->writeln('<info>Found ' . count($tasks) . ' task(s) to run</>');
$this->io->writeln('');
$this->io->writeln('<comment>Running tasks...</comment>');
}
$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('<info>Running task `' . $task['class'] . '`...</>');
}
$this->io->error('<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> [ERROR] ' . $e->getMessage() . ' </>');
}
if ($taskSuccess) {
}
}
// Success
if (!$hasFailure) {
if (!$quiet) {
$this->io->success('Schedule success !');
}
return self::SUCCESS;
} else {
if (!$quiet) {
$this->io->error('Schedule failed !');
}
return self::FAILURE;
}