2010-01-04 14:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
2010-01-04 18:51:21 +00:00
|
|
|
namespace Symfony\Components\CLI\Command;
|
2010-01-04 14:42:28 +00:00
|
|
|
|
2010-01-08 10:00:18 +00:00
|
|
|
use Symfony\Components\CLI\Input\InputArgument;
|
|
|
|
use Symfony\Components\CLI\Input\InputOption;
|
2010-01-04 14:42:28 +00:00
|
|
|
use Symfony\Components\CLI\Input\InputInterface;
|
|
|
|
use Symfony\Components\CLI\Output\OutputInterface;
|
|
|
|
use Symfony\Components\CLI\Output\Output;
|
2010-01-04 18:51:21 +00:00
|
|
|
use Symfony\Components\CLI\Command\Command;
|
2010-01-04 14:42:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the symfony framework.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-01-04 18:51:21 +00:00
|
|
|
* ListCommand displays the list of all available commands for the application.
|
2010-01-04 14:42:28 +00:00
|
|
|
*
|
|
|
|
* @package symfony
|
|
|
|
* @subpackage cli
|
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*/
|
2010-01-04 18:51:21 +00:00
|
|
|
class ListCommand extends Command
|
2010-01-04 14:42:28 +00:00
|
|
|
{
|
|
|
|
/**
|
2010-01-04 18:51:21 +00:00
|
|
|
* @see Command
|
2010-01-04 14:42:28 +00:00
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this
|
|
|
|
->setDefinition(array(
|
2010-01-08 10:00:18 +00:00
|
|
|
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
|
|
|
|
new InputOption('xml', null, InputOption::PARAMETER_NONE, 'To output help as XML'),
|
2010-01-04 14:42:28 +00:00
|
|
|
))
|
|
|
|
->setName('list')
|
2010-01-04 18:51:21 +00:00
|
|
|
->setDescription('Lists commands')
|
2010-01-04 14:42:28 +00:00
|
|
|
->setHelp(<<<EOF
|
2010-01-04 18:51:21 +00:00
|
|
|
The <info>list</info> command lists all commands:
|
2010-01-04 14:42:28 +00:00
|
|
|
|
|
|
|
<info>./symfony list</info>
|
|
|
|
|
2010-01-04 18:51:21 +00:00
|
|
|
You can also display the commands for a specific namespace:
|
2010-01-04 14:42:28 +00:00
|
|
|
|
|
|
|
<info>./symfony list test</info>
|
|
|
|
|
|
|
|
You can also output the information as XML by using the <comment>--xml</comment> option:
|
|
|
|
|
|
|
|
<info>./symfony list --xml</info>
|
|
|
|
EOF
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-01-04 18:51:21 +00:00
|
|
|
* @see Command
|
2010-01-04 14:42:28 +00:00
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
if ($input->getOption('xml'))
|
|
|
|
{
|
|
|
|
$output->write($this->application->asXml($input->getArgument('namespace')), Output::OUTPUT_RAW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$output->write($this->application->asText($input->getArgument('namespace')));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|