Remove $quiet as its handled elsewhere
This commit is contained in:
@@ -48,43 +48,30 @@ class ScheduleCommand extends BaseCommand
|
|||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
// Get options
|
$this->io->title("UserFrosting's Scheduler");
|
||||||
$quiet = $input->getOption('quiet');
|
|
||||||
|
|
||||||
if (!$quiet) {
|
|
||||||
$this->io->title("UserFrosting's Scheduler");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare task locator
|
// Prepare task locator
|
||||||
$scheduler = $this->ci->scheduler;
|
$scheduler = $this->ci->scheduler;
|
||||||
|
|
||||||
|
$this->io->writeln('<comment>Checking for tasks to run...</comment>');
|
||||||
if (!$quiet) {
|
|
||||||
$this->io->writeln('<comment>Checking for tasks to run...</comment>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$tasks = [];
|
$tasks = [];
|
||||||
|
|
||||||
// Start by getting tasks
|
// Find which tasks are due
|
||||||
foreach ($scheduler->getTasks() as $task) {
|
foreach ($scheduler->getTasks() as $task) {
|
||||||
if ($task['instance']->isDue()) {
|
if ($task['instance']->isDue()) {
|
||||||
// Add task class to list
|
|
||||||
$tasks[] = $task;
|
$tasks[] = $task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($tasks) == 0) {
|
if (count($tasks) == 0) {
|
||||||
if (!$quiet) {
|
$this->io->success('Nothing to do');
|
||||||
$this->io->success('Nothing to do');
|
|
||||||
}
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$quiet) {
|
$this->io->writeln('<info>Found ' . count($tasks) . ' task(s) to run</>');
|
||||||
$this->io->writeln('<info>Found ' . count($tasks) . ' task(s) to run</>');
|
$this->io->writeln('');
|
||||||
$this->io->writeln('');
|
$this->io->writeln('<comment>Running tasks...</comment>');
|
||||||
$this->io->writeln('<comment>Running tasks...</comment>');
|
|
||||||
}
|
|
||||||
|
|
||||||
$hasFailure = false;
|
$hasFailure = false;
|
||||||
|
|
||||||
@@ -95,20 +82,10 @@ class ScheduleCommand extends BaseCommand
|
|||||||
$start = hrtime(true);
|
$start = hrtime(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!$task['instance']->run()) {
|
||||||
if (!($taskSuccess = $task['instance']->run())) {
|
|
||||||
throw new Exception('Task returned failure');
|
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);
|
$end = hrtime(true);
|
||||||
|
|
||||||
$tdiff = round(($end-$start) / 1e+6);
|
$tdiff = round(($end-$start) / 1e+6);
|
||||||
@@ -119,19 +96,22 @@ class ScheduleCommand extends BaseCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->io->writeln($tdiff . $tunit);
|
$this->io->writeln($tdiff . $tunit);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$taskSuccess = false;
|
||||||
|
$hasFailure = true;
|
||||||
|
$this->io->writeln('<error> [ERROR] ' . $e->getMessage() . ' </>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($taskSuccess) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
if (!$hasFailure) {
|
if (!$hasFailure) {
|
||||||
if (!$quiet) {
|
$this->io->success('Schedule success !');
|
||||||
$this->io->success('Schedule success !');
|
|
||||||
}
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
if (!$quiet) {
|
$this->io->error('Schedule failed !');
|
||||||
$this->io->error('Schedule failed !');
|
|
||||||
}
|
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user