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 Symfony\Component\Console\Command\Command;
16 use Drupal\Console\Core\Command\Shared\CommandTrait;
17 use Drupal\Console\Core\Style\DrupalStyle;
18 use Drupal\Console\Core\Helper\DescriptorHelper;
21 * HelpCommand displays the help for a given command.
23 * @author Fabien Potencier <fabien@symfony.com>
25 class HelpCommand extends Command
34 protected function configure()
36 $this->ignoreValidationErrors();
40 ->setDefinition($this->createDefinition())
41 ->setDescription($this->trans('commands.help.description'))
42 ->setHelp($this->trans('commands.help.help'));
51 public function setCommand($command)
53 $this->command = $command;
59 protected function execute(InputInterface $input, OutputInterface $output)
61 $io = new DrupalStyle($input, $output);
63 if (null === $this->command) {
64 $this->command = $this->getApplication()->find($input->getArgument('command_name'));
67 if ($input->getOption('xml')) {
68 $io->info($this->trans('commands.help.messages.deprecated'), E_USER_DEPRECATED);
69 $input->setOption('format', 'xml');
72 $helper = new DescriptorHelper();
77 'format' => $input->getOption('format'),
78 'raw_text' => $input->getOption('raw'),
79 'command_name' => $input->getArgument('command_name'),
80 'translator' => $this->getApplication()->getTranslator()
84 $this->command = null;
90 private function createDefinition()
92 return new InputDefinition(
94 new InputArgument('command_name', InputArgument::OPTIONAL, $this->trans('commands.help.arguments.command_name'), 'help'),
95 new InputOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.help.options.xml')),
96 new InputOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.help.options.raw')),
97 new InputOption('format', null, InputOption::VALUE_REQUIRED, $this->trans('commands.help.options.format'), 'txt'),