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;
20 * @package Drupal\Console\Core\Command
22 class ListCommand extends Command
29 protected function configure()
33 ->setDefinition($this->createDefinition())
34 ->setDescription($this->trans('commands.list.description'))
35 ->setHelp($this->trans('commands.list.help'));
41 public function getNativeDefinition()
43 return $this->createDefinition();
49 protected function execute(InputInterface $input, OutputInterface $output)
51 $io = new DrupalStyle($input, $output);
53 if ($input->getOption('xml')) {
55 'The --xml option was deprecated in version 2.7 and will be removed in version 3.0. Use the --format option instead',
58 $input->setOption('format', 'xml');
60 $helper = new DescriptorHelper();
63 $this->getApplication(),
65 'format' => $input->getOption('format'),
66 'raw_text' => $input->getOption('raw'),
67 'namespace' => $input->getArgument('namespace'),
68 'translator' => $this->getApplication()->getTranslator()
76 private function createDefinition()
78 return new InputDefinition(
80 new InputArgument('namespace', InputArgument::OPTIONAL, $this->trans('commands.list.arguments.namespace')),
81 new InputOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.list.options.xml')),
82 new InputOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.list.options.raw')),
83 new InputOption('format', null, InputOption::VALUE_REQUIRED, $this->trans('commands.list.options.format'), 'txt'),