X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FHelpCommand.php;fp=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FHelpCommand.php;h=a13fef660c284e4d455a8a08a4d06b19e6f0430c;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/vendor/drupal/console-core/src/Command/HelpCommand.php b/vendor/drupal/console-core/src/Command/HelpCommand.php new file mode 100644 index 000000000..a13fef660 --- /dev/null +++ b/vendor/drupal/console-core/src/Command/HelpCommand.php @@ -0,0 +1,101 @@ + + */ +class HelpCommand extends Command +{ + use CommandTrait; + + private $command; + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->ignoreValidationErrors(); + + $this + ->setName('help') + ->setDefinition($this->createDefinition()) + ->setDescription($this->trans('commands.help.description')) + ->setHelp($this->trans('commands.help.help')); + } + + /** + * Sets the command. + * + * @param $command + * The command to set + */ + public function setCommand($command) + { + $this->command = $command; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + if (null === $this->command) { + $this->command = $this->getApplication()->find($input->getArgument('command_name')); + } + + if ($input->getOption('xml')) { + $io->info($this->trans('commands.help.messages.deprecated'), E_USER_DEPRECATED); + $input->setOption('format', 'xml'); + } + + $helper = new DescriptorHelper(); + $helper->describe( + $io, + $this->command, + [ + 'format' => $input->getOption('format'), + 'raw_text' => $input->getOption('raw'), + 'command_name' => $input->getArgument('command_name'), + 'translator' => $this->getApplication()->getTranslator() + ] + ); + + $this->command = null; + } + + /** + * {@inheritdoc} + */ + private function createDefinition() + { + return new InputDefinition( + array( + new InputArgument('command_name', InputArgument::OPTIONAL, $this->trans('commands.help.arguments.command_name'), 'help'), + new InputOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.help.options.xml')), + new InputOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.help.options.raw')), + new InputOption('format', null, InputOption::VALUE_REQUIRED, $this->trans('commands.help.options.format'), 'txt'), + ) + ); + } +}