5 * Contains \Drupal\Console\Core\Command\HelpCommand.
8 namespace Drupal\Console\Core\Command;
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;
18 * HelpCommand displays the help for a given command.
20 * @author Fabien Potencier <fabien@symfony.com>
22 class HelpCommand extends Command
29 protected function configure()
31 $this->ignoreValidationErrors();
35 ->setDefinition($this->createDefinition())
36 ->setDescription($this->trans('commands.help.description'))
37 ->setHelp($this->trans('commands.help.help'));
46 public function setCommand($command)
48 $this->command = $command;
54 protected function execute(InputInterface $input, OutputInterface $output)
56 if (null === $this->command) {
57 $this->command = $this->getApplication()->find($input->getArgument('command_name'));
60 if ($input->getOption('xml')) {
61 $this->getIo()->info($this->trans('commands.help.messages.deprecated'), E_USER_DEPRECATED);
62 $input->setOption('format', 'xml');
65 $helper = new DescriptorHelper();
70 'format' => $input->getOption('format'),
71 'raw_text' => $input->getOption('raw'),
72 'command_name' => $input->getArgument('command_name'),
73 'translator' => $this->getApplication()->getTranslator()
77 $this->command = null;
78 $this->getIo()->newLine();
84 private function createDefinition()
86 return new InputDefinition(
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'),