Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / robo / src / Application.php
1 <?php
2 namespace Robo;
3
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;
8
9 class Application extends SymfonyApplication
10 {
11     /**
12      * @param string $name
13      * @param string $version
14      */
15     public function __construct($name, $version)
16     {
17         parent::__construct($name, $version);
18
19         $this->getDefinition()
20             ->addOption(
21                 new InputOption('--simulate', null, InputOption::VALUE_NONE, 'Run in simulated mode (show what would have happened).')
22             );
23         $this->getDefinition()
24             ->addOption(
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)
26             );
27
28         $this->getDefinition()
29             ->addOption(
30                 new InputOption('--define', '-D', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Define a configuration item value.', [])
31             );
32     }
33
34     /**
35      * @param string $roboFile
36      * @param string $roboClass
37      */
38     public function addInitRoboFileCommand($roboFile, $roboClass)
39     {
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>");
46             file_put_contents(
47                 $roboFile,
48                 '<?php'
49                 . "\n/**"
50                 . "\n * This is project's console commands configuration for Robo task runner."
51                 . "\n *"
52                 . "\n * @see http://robo.li/"
53                 . "\n */"
54                 . "\nclass " . $roboClass . " extends \\Robo\\Tasks\n{\n    // define public methods as commands\n}"
55             );
56             $output->writeln("<comment>  Edit this file to add your commands! </comment>");
57         });
58         $this->add($createRoboFile);
59     }
60
61     /**
62      * Add self update command, do nothing if null is provided
63      *
64      * @param string $repository GitHub Repository for self update
65      */
66     public function addSelfUpdateCommand($repository = null)
67     {
68         if (!$repository || empty(\Phar::running())) {
69             return;
70         }
71         $selfUpdateCommand = new SelfUpdateCommand($this->getName(), $this->getVersion(), $repository);
72         $this->add($selfUpdateCommand);
73     }
74 }