4 * Contains \Drupal\Console\Core\Command\ListCommand.
6 namespace Drupal\Console\Core\Command;
8 use Symfony\Component\Console\Input\InputArgument;
9 use Symfony\Component\Console\Input\InputInterface;
10 use Symfony\Component\Console\Input\InputDefinition;
11 use Symfony\Component\Console\Input\InputOption;
12 use Drupal\Console\Core\Helper\DescriptorHelper;
13 use Symfony\Component\Console\Output\OutputInterface;
18 * @package Drupal\Console\Core\Command
20 class ListCommand extends Command
25 protected function configure()
29 ->setDefinition($this->createDefinition())
30 ->setDescription($this->trans('commands.list.description'))
31 ->setHelp($this->trans('commands.list.help'));
37 public function getNativeDefinition()
39 return $this->createDefinition();
45 protected function execute(InputInterface $input, OutputInterface $output)
47 if ($input->getOption('xml')) {
49 'The --xml option was deprecated in version 2.7 and will be removed in version 3.0. Use the --format option instead',
52 $input->setOption('format', 'xml');
54 $commandName = $input->getFirstArgument()?$input->getFirstArgument():'help';
55 $helper = new DescriptorHelper();
58 $this->getApplication(),
60 'format' => $input->getOption('format'),
61 'raw_text' => $input->getOption('raw'),
62 'namespace' => $input->getArgument('namespace'),
63 'translator' => $this->getApplication()->getTranslator(),
64 'command' => $this->getApplication()->find($commandName)
68 $this->getIo()->newLine();
74 private function createDefinition()
76 return new InputDefinition(
78 new InputArgument('namespace', InputArgument::OPTIONAL, $this->trans('commands.list.arguments.namespace')),
79 new InputOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.list.options.xml')),
80 new InputOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.list.options.raw')),
81 new InputOption('format', null, InputOption::VALUE_REQUIRED, $this->trans('commands.list.options.format'), 'txt'),