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: use Symfony\Component\Console\Input\InputDefinition;
20: 
21: /**
22:  * ListCommand displays the list of all available commands for the application.
23:  *
24:  * @author Fabien Potencier <fabien@symfony.com>
25:  */
26: class ListCommand extends Command
27: {
28:     /**
29:      * {@inheritdoc}
30:      */
31:     protected function configure()
32:     {
33:         $this
34:             ->setName('list')
35:             ->setDefinition($this->createDefinition())
36:             ->setDescription('Lists commands')
37:             ->setHelp(<<<EOF
38: The <info>%command.name%</info> command lists all commands:
39: 
40:   <info>php %command.full_name%</info>
41: 
42: You can also display the commands for a specific namespace:
43: 
44:   <info>php %command.full_name% test</info>
45: 
46: You can also output the information as XML by using the <comment>--xml</comment> option:
47: 
48:   <info>php %command.full_name% --xml</info>
49: 
50: It's also possible to get raw list of commands (useful for embedding command runner):
51: 
52:   <info>php %command.full_name% --raw</info>
53: EOF
54:             )
55:         ;
56:     }
57: 
58:     /**
59:      * {@inheritdoc}
60:      */
61:     protected function getNativeDefinition()
62:     {
63:         return $this->createDefinition();
64:     }
65: 
66:     /**
67:      * {@inheritdoc}
68:      */
69:     protected function execute(InputInterface $input, OutputInterface $output)
70:     {
71:         if ($input->getOption('xml')) {
72:             $output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW);
73:         } else {
74:             $output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw')));
75:         }
76:     }
77: 
78:     private function createDefinition()
79:     {
80:         return new InputDefinition(array(
81:             new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
82:             new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
83:             new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
84:         ));
85:     }
86: }
87: 
php-coveralls API documentation generated by ApiGen 2.8.0