Explorar o código

[Console] removed the ? alias for help and fix a few bugs from the previous commit

Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
d84728e278

+ 6 - 2
src/Symfony/Component/Console/Application.php

@@ -457,7 +457,7 @@ class Application
             }
         }
 
-        return array_unique(array_filter($namespaces));
+        return array_values(array_unique(array_filter($namespaces)));
     }
 
     /**
@@ -578,7 +578,7 @@ class Application
 
         $commands = array();
         foreach ($this->commands as $name => $command) {
-            if ($namespace === $this->extractNamespace($command->getName())) {
+            if ($namespace === $this->extractNamespace($name)) {
                 $commands[$name] = $command;
             }
         }
@@ -687,6 +687,10 @@ class Application
             }
 
             foreach ($commands as $name => $command) {
+                if ($name !== $command->getName()) {
+                    continue;
+                }
+
                 if (!$namespace) {
                     $commandXML = $dom->createElement('command');
                     $namespaceArrayXML->appendChild($commandXML);

+ 0 - 1
src/Symfony/Component/Console/Command/HelpCommand.php

@@ -40,7 +40,6 @@ class HelpCommand extends Command
                 new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
             ))
             ->setName('help')
-            ->setAliases(array('?'))
             ->setDescription('Displays help for a command')
             ->setHelp(<<<EOF
 The <info>help</info> command displays help for a given command:

+ 3 - 2
tests/Symfony/Tests/Component/Console/Fixtures/application_astext1.txt

@@ -12,7 +12,8 @@
   <info>--no-interaction</info> <info>-n</info> Do not ask any interactive question.
 
 <comment>Available commands:</comment>
-  <info>help     </info> Displays help for a command<comment> (?)</comment>
+  <info>afoobar  </info> The foo:bar command
+  <info>help     </info> Displays help for a command
   <info>list     </info> Lists commands
 <comment>foo</comment>
-  <info>foo:bar  </info> The foo:bar command<comment> (afoobar)</comment>
+  <info>foo:bar  </info> The foo:bar command

+ 1 - 1
tests/Symfony/Tests/Component/Console/Fixtures/application_astext2.txt

@@ -12,4 +12,4 @@
   <info>--no-interaction</info> <info>-n</info> Do not ask any interactive question.
 
 <comment>Available commands for the "foo" namespace:</comment>
-  <info>foo:bar  </info> The foo:bar command<comment> (afoobar)</comment>
+  <info>foo:bar  </info> The foo:bar command

+ 1 - 3
tests/Symfony/Tests/Component/Console/Fixtures/application_asxml1.txt

@@ -11,9 +11,7 @@
  You can also output the help as XML by using the &lt;comment&gt;--xml&lt;/comment&gt; option:
  
    &lt;info&gt;./symfony help --xml list&lt;/info&gt;</help>
-  <aliases>
-    <alias>?</alias>
-  </aliases>
+  <aliases />
   <arguments>
     <argument name="command_name" is_required="0" is_array="0">
       <description>The command name</description>

+ 1 - 1
tests/Symfony/Tests/Component/Console/Fixtures/application_run1.txt

@@ -12,5 +12,5 @@ Options:
   --no-interaction -n Do not ask any interactive question.
 
 Available commands:
-  help   Displays help for a command (?)
+  help   Displays help for a command
   list   Lists commands

+ 0 - 1
tests/Symfony/Tests/Component/Console/Fixtures/application_run2.txt

@@ -1,7 +1,6 @@
 Usage:
  help [--xml] [command_name]
 
-Aliases: ?
 Arguments:
  command           The command to execute
  command_name      The command name (default: help)