Sfoglia il codice sorgente

provided unmerged definition for correct help generation

Andreas Hucks 13 anni fa
parent
commit
705e46018e
1 ha cambiato i file con 18 aggiunte e 4 eliminazioni
  1. 18 4
      src/Symfony/Component/Console/Command/ListCommand.php

+ 18 - 4
src/Symfony/Component/Console/Command/ListCommand.php

@@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Output\Output;
 use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputDefinition;
 
 /**
  * ListCommand displays the list of all available commands for the application.
@@ -31,10 +32,7 @@ class ListCommand extends Command
     protected function configure()
     {
         $this
-            ->setDefinition(array(
-                new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
-                new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
-            ))
+            ->setDefinition($this->createDefinition())
             ->setName('list')
             ->setDescription('Lists commands')
             ->setHelp(<<<EOF
@@ -53,6 +51,14 @@ EOF
             );
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    protected function getNativeDefinition()
+    {
+        return $this->createDefinition();
+    }
+
     /**
      * {@inheritdoc}
      */
@@ -64,4 +70,12 @@ EOF
             $output->writeln($this->getApplication()->asText($input->getArgument('namespace')));
         }
     }
+
+    private function createDefinition()
+    {
+        return new InputDefinition(array(
+            new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
+            new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
+        ));
+    }
 }