Skip to content

Commit

Permalink
[Console] Add namespace support back in to list command
Browse files Browse the repository at this point in the history
  • Loading branch information
xanido committed May 22, 2013
1 parent 55f2000 commit 79a842a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Command/ListCommand.php
Expand Up @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$helper = new DescriptorHelper();
$helper->describe($output, $this->getApplication(), $input->getOption('format'), $input->getOption('raw'));
$helper->describe($output, $this->getApplication(), $input->getOption('format'), $input->getOption('raw'), $input->getArgument('namespace'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Helper/DescriptorHelper.php
Expand Up @@ -56,9 +56,9 @@ public function __construct()
* @param string $format
* @param boolean $raw
*/
public function describe(OutputInterface $output, $object, $format = null, $raw = false)
public function describe(OutputInterface $output, $object, $format = null, $raw = false, $namespace = null)
{
$options = array('raw_text' => $raw, 'format' => $format ?: 'txt');
$options = array('raw_text' => $raw, 'format' => $format ?: 'txt', 'namespace' => $namespace);
$type = !$raw && 'txt' === $options['format'] ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW;

if (!isset($this->descriptors[$options['format']])) {
Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/Console/Tests/Command/ListCommandTest.php
Expand Up @@ -42,6 +42,22 @@ public function testExecuteListsCommandsWithRawOption()
help Displays help for a command
list Lists commands
EOF;

$this->assertEquals($output, $commandTester->getDisplay(true));
}

public function testExecuteListsCommandsWithNamespaceArgument()
{

require_once(realpath(__DIR__.'/../Fixtures/FooCommand.php'));
$application = new Application();
$application->add(new \FooCommand());
$commandTester = new CommandTester($command = $application->get('list'));
$commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true));
$output = <<<EOF
foo:bar The foo:bar command
EOF;

$this->assertEquals($output, $commandTester->getDisplay(true));
Expand Down

0 comments on commit 79a842a

Please sign in to comment.