Author: Fabien Potencier (fabien@symfony.com)
Inheritance: extends Command
Esempio n. 1
0
 /**
  * {@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');
 }
Esempio n. 3
0
 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');
 }
Esempio n. 4
0
 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');
 }
Esempio n. 5
0
 /**
  * {@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);
 }
Esempio n. 6
0
    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
);
    }
Esempio n. 7
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setCommand($this->getApplication()->find(LintCommand::COMMAND_NAME));
     parent::execute($input, $output);
 }
Esempio n. 8
0
 /**
  * @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);
 }