/** * {@inheritDoc} */ protected function getCommandName(InputInterface $input) { if ($input->hasOption('help')) { $command = new HelpCommand(); return $command->getName(); } return $this->singleCommandName; }
public function testExecuteForCommandWithXmlOption() { $command = new HelpCommand(); $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array('--format' => 'xml')); $this->assertContains('<command', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed'); }
public function testExecuteForCommandWithXmlOption() { $command = new HelpCommand(); $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array('--xml' => true)); $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed'); }
public function testExecute() { $command = new HelpCommand(); $command->setCommand(new ListCommand()); $commandTester = new CommandTester($command); $commandTester->execute(array()); $this->assertRegExp('/list \\[--xml\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $commandTester->execute(array('--xml' => true)); $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed'); $application = new Application(); $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list')); $this->assertRegExp('/list \\[--xml\\] \\[namespace\\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); $commandTester->execute(array('command_name' => 'list', '--xml' => true)); $this->assertRegExp('/<command/', $commandTester->getDisplay(), '->execute() returns an XML help text if --xml is passed'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { if (null === $this->command) { $this->command = $this->getApplication()->find($input->getArgument('command_name')); } $this->updateCommandDefinition($this->command, $output); parent::execute($input, $output); }
protected function configure() { parent::configure(); $this->setHelp(<<<EOF The <info>%command.name%</info> command displays help for a given command: <info>vagma help <command></info> You can also output the help in other formats by using the <comment>--format</comment> option: <info>vagma help --format=xml list</info> <bg=yellow;fg=black> Beginners => </> To display the list of available commands, please use the <info>list</info> command: <info>vagma list</info> EOF ); }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $this->setCommand($this->getApplication()->find(LintCommand::COMMAND_NAME)); parent::execute($input, $output); }
/** * @param InputInterface $input * @param OutputInterface $output * @return int * @throws \Symfony\Component\Console\Exception\ExceptionInterface */ protected function outputHelp(InputInterface $input, OutputInterface $output) { $help = new HelpCommand(); $help->setCommand($this); return $help->run($input, $output); }