Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • Command
  • HelpCommand
  • ListCommand
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\Console\Command;
13: 
14: use Symfony\Component\Console\Input\InputArgument;
15: use Symfony\Component\Console\Input\InputOption;
16: use Symfony\Component\Console\Input\InputInterface;
17: use Symfony\Component\Console\Output\OutputInterface;
18: use Symfony\Component\Console\Command\Command;
19: 
20: /**
21:  * HelpCommand displays the help for a given command.
22:  *
23:  * @author Fabien Potencier <fabien@symfony.com>
24:  */
25: class HelpCommand extends Command
26: {
27:     private $command;
28: 
29:     /**
30:      * {@inheritdoc}
31:      */
32:     protected function configure()
33:     {
34:         $this->ignoreValidationErrors();
35: 
36:         $this
37:             ->setName('help')
38:             ->setDefinition(array(
39:                 new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
40:                 new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
41:             ))
42:             ->setDescription('Displays help for a command')
43:             ->setHelp(<<<EOF
44: The <info>%command.name%</info> command displays help for a given command:
45: 
46:   <info>php %command.full_name% list</info>
47: 
48: You can also output the help as XML by using the <comment>--xml</comment> option:
49: 
50:   <info>php %command.full_name% --xml list</info>
51: 
52: To display the list of available commands, please use the <info>list</info> command.
53: EOF
54:             )
55:         ;
56:     }
57: 
58:     /**
59:      * Sets the command
60:      *
61:      * @param Command $command The command to set
62:      */
63:     public function setCommand(Command $command)
64:     {
65:         $this->command = $command;
66:     }
67: 
68:     /**
69:      * {@inheritdoc}
70:      */
71:     protected function execute(InputInterface $input, OutputInterface $output)
72:     {
73:         if (null === $this->command) {
74:             $this->command = $this->getApplication()->find($input->getArgument('command_name'));
75:         }
76: 
77:         if ($input->getOption('xml')) {
78:             $output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW);
79:         } else {
80:             $output->writeln($this->command->asText());
81:         }
82: 
83:         $this->command = null;
84:     }
85: }
86: 
php-coveralls API documentation generated by ApiGen 2.8.0