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