Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / drupal / console-core / src / Command / HelpCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Core\Command\HelpCommand.
6  */
7
8 namespace Drupal\Console\Core\Command;
9
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Input\InputDefinition;
14 use Symfony\Component\Console\Output\OutputInterface;
15 use Drupal\Console\Core\Helper\DescriptorHelper;
16
17 /**
18  * HelpCommand displays the help for a given command.
19  *
20  * @author Fabien Potencier <fabien@symfony.com>
21  */
22 class HelpCommand extends Command
23 {
24     private $command;
25
26     /**
27      * {@inheritdoc}
28      */
29     protected function configure()
30     {
31         $this->ignoreValidationErrors();
32
33         $this
34             ->setName('help')
35             ->setDefinition($this->createDefinition())
36             ->setDescription($this->trans('commands.help.description'))
37             ->setHelp($this->trans('commands.help.help'));
38     }
39
40     /**
41      * Sets the command.
42      *
43      * @param $command
44      *  The command to set
45      */
46     public function setCommand($command)
47     {
48         $this->command = $command;
49     }
50
51     /**
52      * {@inheritdoc}
53      */
54     protected function execute(InputInterface $input, OutputInterface $output)
55     {
56         if (null === $this->command) {
57             $this->command = $this->getApplication()->find($input->getArgument('command_name'));
58         }
59
60         if ($input->getOption('xml')) {
61             $this->getIo()->info($this->trans('commands.help.messages.deprecated'), E_USER_DEPRECATED);
62             $input->setOption('format', 'xml');
63         }
64
65         $helper = new DescriptorHelper();
66         $helper->describe(
67             $this->getIo(),
68             $this->command,
69             [
70                 'format' => $input->getOption('format'),
71                 'raw_text' => $input->getOption('raw'),
72                 'command_name' => $input->getArgument('command_name'),
73                 'translator' => $this->getApplication()->getTranslator()
74             ]
75         );
76
77         $this->command = null;
78         $this->getIo()->newLine();
79     }
80
81     /**
82      * {@inheritdoc}
83      */
84     private function createDefinition()
85     {
86         return new InputDefinition(
87             [
88             new InputArgument('command_name', InputArgument::OPTIONAL, $this->trans('commands.help.arguments.command-name'), 'help'),
89             new InputOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.help.options.xml')),
90             new InputOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.help.options.raw')),
91             new InputOption('format', null, InputOption::VALUE_REQUIRED, $this->trans('commands.help.options.format'), 'txt'),
92             ]
93         );
94     }
95 }