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;
14 use Symfony\Component\Console\Command\Command;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Core\Style\DrupalStyle;
21 * @package Drupal\Console\Core\Command
23 class ListCommand extends Command
30 protected function configure()
34 ->setDefinition($this->createDefinition())
35 ->setDescription($this->trans('commands.list.description'))
36 ->setHelp($this->trans('commands.list.help'));
42 public function getNativeDefinition()
44 return $this->createDefinition();
50 protected function execute(InputInterface $input, OutputInterface $output)
52 $io = new DrupalStyle($input, $output);
54 if ($input->getOption('xml')) {
56 'The --xml option was deprecated in version 2.7 and will be removed in version 3.0. Use the --format option instead',
59 $input->setOption('format', 'xml');
61 $helper = new DescriptorHelper();
64 $this->getApplication(),
66 'format' => $input->getOption('format'),
67 'raw_text' => $input->getOption('raw'),
68 'namespace' => $input->getArgument('namespace'),
69 'translator' => $this->getApplication()->getTranslator()
77 private function createDefinition()
79 return new InputDefinition(
81 new InputArgument('namespace', InputArgument::OPTIONAL, $this->trans('commands.list.arguments.namespace')),
82 new InputOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.list.options.xml')),
83 new InputOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.list.options.raw')),
84 new InputOption('format', null, InputOption::VALUE_REQUIRED, $this->trans('commands.list.options.format'), 'txt'),