* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ /** * ListCommand displays the list of all available commands for the application. * * @author Fabien Potencier */ class ListCommand extends Command { /** * @see 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'), )) ->setName('list') ->setDescription('Lists commands') ->setHelp(<<list command lists all commands: ./symfony list You can also display the commands for a specific namespace: ./symfony list test You can also output the information as XML by using the --xml option: ./symfony list --xml EOF ); } /** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('xml')) { $output->writeln($this->application->asXml($input->getArgument('namespace')), Output::OUTPUT_RAW); } else { $output->writeln($this->application->asText($input->getArgument('namespace'))); } } }