4 use SelfUpdate\SelfUpdateCommand;
5 use Symfony\Component\Console\Application as SymfonyApplication;
6 use Symfony\Component\Console\Command\Command;
7 use Symfony\Component\Console\Input\InputOption;
9 class Application extends SymfonyApplication
13 * @param string $version
15 public function __construct($name, $version)
17 parent::__construct($name, $version);
19 $this->getDefinition()
21 new InputOption('--simulate', null, InputOption::VALUE_NONE, 'Run in simulated mode (show what would have happened).')
23 $this->getDefinition()
25 new InputOption('--progress-delay', null, InputOption::VALUE_REQUIRED, 'Number of seconds before progress bar is displayed in long-running task collections. Default: 2s.', Config::DEFAULT_PROGRESS_DELAY)
28 $this->getDefinition()
30 new InputOption('--define', '-D', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Define a configuration item value.', [])
35 * @param string $roboFile
36 * @param string $roboClass
38 public function addInitRoboFileCommand($roboFile, $roboClass)
40 $createRoboFile = new Command('init');
41 $createRoboFile->setDescription("Intitalizes basic RoboFile in current dir");
42 $createRoboFile->setCode(function () use ($roboClass, $roboFile) {
43 $output = Robo::output();
44 $output->writeln("<comment> ~~~ Welcome to Robo! ~~~~ </comment>");
45 $output->writeln("<comment> ". basename($roboFile) ." will be created in the current directory </comment>");
50 . "\n * This is project's console commands configuration for Robo task runner."
52 . "\n * @see http://robo.li/"
54 . "\nclass " . $roboClass . " extends \\Robo\\Tasks\n{\n // define public methods as commands\n}"
56 $output->writeln("<comment> Edit this file to add your commands! </comment>");
58 $this->add($createRoboFile);
62 * Add self update command, do nothing if null is provided
64 * @param string $repository GitHub Repository for self update
66 public function addSelfUpdateCommand($repository = null)
68 if (!$repository || empty(\Phar::running())) {
71 $selfUpdateCommand = new SelfUpdateCommand($this->getName(), $this->getVersion(), $repository);
72 $this->add($selfUpdateCommand);