Skip to content

Commit

Permalink
Help command [contributte#1]
Browse files Browse the repository at this point in the history
  • Loading branch information
josefbenjac committed Jan 9, 2018
1 parent 970199d commit 0ec6d6d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Contributte\Scheduler\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class HelpCommand extends Command
{

/**
* @return void
*/
protected function configure()
{
$this->setName('scheduler:help')
->setDescription('Print cron syntax');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln('Cron syntax: ');
$output->writeln('
* * * * *
- - - - -
| | | | |
| | | | |
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
| | | +---------- month (1 - 12)
| | +--------------- day of month (1 - 31)
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)');
$output->writeln('');
return 0;
}

}
4 changes: 4 additions & 0 deletions src/DI/SchedulerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Contributte\Scheduler\DI;

use Contributte\Scheduler\CallbackJob;
use Contributte\Scheduler\Command\HelpCommand;
use Contributte\Scheduler\Command\ListCommand;
use Contributte\Scheduler\Command\RunCommand;
use Contributte\Scheduler\LockingScheduler;
Expand Down Expand Up @@ -41,6 +42,9 @@ public function loadConfiguration()
$builder->addDefinition($this->prefix('listCommand'))
->setClass(ListCommand::class)
->setAutowired(FALSE);
$builder->addDefinition($this->prefix('helpCommand'))
->setClass(HelpCommand::class)
->setAutowired(FALSE);

// Jobs
foreach ($config['jobs'] as $job) {
Expand Down

0 comments on commit 0ec6d6d

Please sign in to comment.