File tree Expand file tree Collapse file tree 3 files changed +50
-3
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 3 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -134,15 +134,17 @@ private function inspectApplication()
134
134
private function sortCommands (array $ commands )
135
135
{
136
136
$ namespacedCommands = array ();
137
+ $ globalCommands = array ();
137
138
foreach ($ commands as $ name => $ command ) {
138
139
$ key = $ this ->application ->extractNamespace ($ name , 1 );
139
140
if (!$ key ) {
140
- $ key = '_global ' ;
141
+ $ globalCommands ['_global ' ][$ name ] = $ command ;
142
+ } else {
143
+ $ namespacedCommands [$ key ][$ name ] = $ command ;
141
144
}
142
-
143
- $ namespacedCommands [$ key ][$ name ] = $ command ;
144
145
}
145
146
ksort ($ namespacedCommands );
147
+ $ namespacedCommands = array_merge ($ globalCommands , $ namespacedCommands );
146
148
147
149
foreach ($ namespacedCommands as &$ commandsSet ) {
148
150
ksort ($ commandsSet );
Original file line number Diff line number Diff line change @@ -61,4 +61,36 @@ public function testExecuteListsCommandsWithNamespaceArgument()
61
61
62
62
$ this ->assertEquals ($ output , $ commandTester ->getDisplay (true ));
63
63
}
64
+
65
+ public function testExecuteListsCommandsNameAndNamespaceRaw ()
66
+ {
67
+ require_once realpath (__DIR__ .'/../Fixtures/Foo6Command.php ' );
68
+ $ application = new Application ();
69
+ $ application ->add (new \Foo6Command ());
70
+ $ commandTester = new CommandTester ($ command = $ application ->get ('list ' ));
71
+ $ commandTester ->execute (array ('command ' => $ command ->getName ()));
72
+ $ output = <<<EOF
73
+ Console Tool
74
+
75
+ Usage:
76
+ [options] command [arguments]
77
+
78
+ Options:
79
+ --help (-h) Display this help message.
80
+ --quiet (-q) Do not output any message.
81
+ --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
82
+ --version (-V) Display this application version.
83
+ --ansi Force ANSI output.
84
+ --no-ansi Disable ANSI output.
85
+ --no-interaction (-n) Do not ask any interactive question.
86
+
87
+ Available commands:
88
+ help Displays help for a command
89
+ list Lists commands
90
+ <fg=blue>foo
91
+ <fg=blue>foo:bar</fg=blue>
92
+ EOF ;
93
+
94
+ $ this ->assertEquals ($ output , trim ($ commandTester ->getDisplay (true )));
95
+ }
64
96
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+
4
+ use Symfony \Component \Console \Command \Command ;
5
+
6
+ class Foo6Command extends Command
7
+ {
8
+ protected function configure ()
9
+ {
10
+ $ this ->setName ('<fg=blue>foo:bar</fg=blue> ' );
11
+ }
12
+
13
+ }
You can’t perform that action at this time.
0 commit comments