1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Bowerphp. |
5
|
|
|
* |
6
|
|
|
* (c) Massimiliano Arione <[email protected]> |
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 Bowerphp\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Command\ListCommand; |
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
16
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
17
|
|
|
use Symfony\Component\Console\Input\InputOption; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* CommandList: this command shows a list of available commands. |
21
|
|
|
* It's just an extension of original ListCommand, needed to change "list" name |
22
|
|
|
*/ |
23
|
|
|
class CommandListCommand extends ListCommand |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
protected function configure() |
29
|
|
|
{ |
30
|
|
|
$this |
31
|
|
|
->setName('list-commands') |
32
|
|
|
->setDefinition($this->createDefinition()) |
33
|
|
|
->setDescription('Lists commands') |
34
|
|
|
->setHelp(<<<'EOF' |
35
|
|
|
The <info>%command.name%</info> command lists all commands: |
36
|
|
|
|
37
|
|
|
<info>php %command.full_name%</info> |
38
|
|
|
|
39
|
|
|
You can also display the commands for a specific namespace: |
40
|
|
|
|
41
|
|
|
<info>php %command.full_name% test</info> |
42
|
|
|
|
43
|
|
|
You can also output the information in other formats by using the <comment>--format</comment> option: |
44
|
|
|
|
45
|
|
|
<info>php %command.full_name% --format=xml</info> |
46
|
|
|
|
47
|
|
|
It's also possible to get raw list of commands (useful for embedding command runner): |
48
|
|
|
|
49
|
|
|
<info>php %command.full_name% --raw</info> |
50
|
|
|
EOF |
51
|
|
|
) |
52
|
|
|
; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
private function createDefinition() |
59
|
|
|
{ |
60
|
|
|
return new InputDefinition([ |
61
|
|
|
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), |
62
|
|
|
new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'), |
63
|
|
|
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), |
64
|
|
|
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output list in other formats', 'txt'), |
65
|
|
|
]); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|