summaryrefslogtreecommitdiff
path: root/vendor/symfony/console/Command/ListCommand.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2024-08-13 23:45:21 +0200
committerpolo <ordipolo@gmx.fr>2024-08-13 23:45:21 +0200
commitbf6655a534a6775d30cafa67bd801276bda1d98d (patch)
treec6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/symfony/console/Command/ListCommand.php
parent94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff)
downloadAppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/symfony/console/Command/ListCommand.php')
-rw-r--r--vendor/symfony/console/Command/ListCommand.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/symfony/console/Command/ListCommand.php b/vendor/symfony/console/Command/ListCommand.php
new file mode 100644
index 0000000..61b4b1b
--- /dev/null
+++ b/vendor/symfony/console/Command/ListCommand.php
@@ -0,0 +1,72 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Console\Command;
13
14use Symfony\Component\Console\Descriptor\ApplicationDescription;
15use Symfony\Component\Console\Helper\DescriptorHelper;
16use Symfony\Component\Console\Input\InputArgument;
17use Symfony\Component\Console\Input\InputInterface;
18use Symfony\Component\Console\Input\InputOption;
19use Symfony\Component\Console\Output\OutputInterface;
20
21/**
22 * ListCommand displays the list of all available commands for the application.
23 *
24 * @author Fabien Potencier <fabien@symfony.com>
25 */
26class ListCommand extends Command
27{
28 protected function configure(): void
29 {
30 $this
31 ->setName('list')
32 ->setDefinition([
33 new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name', null, fn () => array_keys((new ApplicationDescription($this->getApplication()))->getNamespaces())),
34 new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
35 new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt', fn () => (new DescriptorHelper())->getFormats()),
36 new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'),
37 ])
38 ->setDescription('List commands')
39 ->setHelp(<<<'EOF'
40The <info>%command.name%</info> command lists all commands:
41
42 <info>%command.full_name%</info>
43
44You can also display the commands for a specific namespace:
45
46 <info>%command.full_name% test</info>
47
48You can also output the information in other formats by using the <comment>--format</comment> option:
49
50 <info>%command.full_name% --format=xml</info>
51
52It's also possible to get raw list of commands (useful for embedding command runner):
53
54 <info>%command.full_name% --raw</info>
55EOF
56 )
57 ;
58 }
59
60 protected function execute(InputInterface $input, OutputInterface $output): int
61 {
62 $helper = new DescriptorHelper();
63 $helper->describe($output, $this->getApplication(), [
64 'format' => $input->getOption('format'),
65 'raw_text' => $input->getOption('raw'),
66 'namespace' => $input->getArgument('namespace'),
67 'short' => $input->getOption('short'),
68 ]);
69
70 return 0;
71 }
72}