diff --git a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php
index cdf1493c40217..33fd35e6e0c61 100644
--- a/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php
+++ b/src/Symfony/Component/Console/Descriptor/ApplicationDescription.php
@@ -134,15 +134,17 @@ private function inspectApplication()
private function sortCommands(array $commands)
{
$namespacedCommands = array();
+ $globalCommands = array();
foreach ($commands as $name => $command) {
$key = $this->application->extractNamespace($name, 1);
if (!$key) {
- $key = '_global';
+ $globalCommands['_global'][$name] = $command;
+ } else {
+ $namespacedCommands[$key][$name] = $command;
}
-
- $namespacedCommands[$key][$name] = $command;
}
ksort($namespacedCommands);
+ $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
foreach ($namespacedCommands as &$commands) {
ksort($commands);
diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php
index 72c485bbe9615..798d5820c7e7f 100644
--- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php
@@ -195,13 +195,15 @@ protected function describeApplication(Application $application, array $options
// add commands by namespace
foreach ($description->getNamespaces() as $namespace) {
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
- $this->writeText("\n");
- $this->writeText(''.$namespace['id'].'', $options);
+ $this->writeText("\n", $options);
+ $this->writeText($namespace['id'], array_merge($options, array('raw_output' => true)));
+ $this->writeText("", $options);
}
foreach ($namespace['commands'] as $name) {
- $this->writeText("\n");
- $this->writeText(sprintf(" %-${width}s %s", $name, $description->getCommand($name)->getDescription()), $options);
+ $this->writeText("\n ", $options);
+ $this->writeText(sprintf("%-${width}s", $name), array_merge($options, array('raw_output' => true)));
+ $this->writeText(sprintf(" %s", $description->getCommand($name)->getDescription()), $options);
}
}
diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php
index fbb9feeb68731..9e099eb4eec4d 100644
--- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php
+++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php
@@ -61,4 +61,17 @@ public function testExecuteListsCommandsWithNamespaceArgument()
$this->assertEquals($output, $commandTester->getDisplay(true));
}
+
+ public function testExecuteListsCommandsNameAndNamespaceRaw()
+ {
+ require_once realpath(__DIR__.'/../Fixtures/Foo6Command.php');
+ $application = new Application();
+ $application->add(new \Foo6Command());
+ $commandTester = new CommandTester($command = $application->get('list'));
+ $commandTester->execute(array('command' => $command->getName()));
+
+ $regex = '/Available commands:\s*help\s*.*\s*list.*\s*foo\s*foo:bar<\/fg=blue>/';
+
+ $this->assertRegExp($regex, $commandTester->getDisplay(true));
+ }
}
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php
new file mode 100644
index 0000000000000..78fa91eaa8931
--- /dev/null
+++ b/src/Symfony/Component/Console/Tests/Fixtures/Foo6Command.php
@@ -0,0 +1,13 @@
+setName('foo:bar');
+ }
+
+}
\ No newline at end of file