저자: Fabien Potencier (fabien@symfony.com)
상속: extends Command
예제 #1
0
 /**
  * {@inheritDoc}
  */
 protected function getCommandName(InputInterface $input)
 {
     if ($input->hasOption('help')) {
         $command = new HelpCommand();
         return $command->getName();
     }
     return $this->singleCommandName;
 }
예제 #2
0
 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');
 }
예제 #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');
 }
예제 #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');
 }
예제 #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);
 }
예제 #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
);
    }
예제 #7
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setCommand($this->getApplication()->find(LintCommand::COMMAND_NAME));
     parent::execute($input, $output);
 }
예제 #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);
 }