diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php
index 8aceb5c0a66df..6a67d9d89d5df 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php
@@ -31,6 +31,7 @@ class DebugAutowiringCommand extends ContainerDebugCommand
{
protected static $defaultName = 'debug:autowiring';
protected static $defaultDescription = 'Lists classes/interfaces you can use for autowiring';
+
private $supportsHref;
private $fileLinkFormatter;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
index 0b5bb061d66e2..bffd08b6598f4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
@@ -25,6 +25,7 @@
class XliffLintCommand extends BaseLintCommand
{
protected static $defaultName = 'lint:xliff';
+ protected static $defaultDescription = 'Lints a XLIFF file and outputs encountered errors';
public function __construct()
{
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
index 1163ff1c28fb1..5c65b09a61b46 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
@@ -24,6 +24,7 @@
class YamlLintCommand extends BaseLintCommand
{
protected static $defaultName = 'lint:yaml';
+ protected static $defaultDescription = 'Lints a file and outputs encountered errors';
public function __construct()
{
diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
index f6e6b054faf56..1a5ff90fb6cd4 100644
--- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
+++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php
@@ -22,6 +22,9 @@
*/
final class LintCommand extends BaseLintCommand
{
+ protected static $defaultName = 'lint:twig';
+ protected static $defaultDescription = 'Lints a template and outputs encountered errors';
+
/**
* {@inheritdoc}
*/
diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md
index 37689ab692db1..cf4610f2f35c9 100644
--- a/src/Symfony/Component/Console/CHANGELOG.md
+++ b/src/Symfony/Component/Console/CHANGELOG.md
@@ -8,6 +8,7 @@ CHANGELOG
* Add `InputOption::VALUE_NEGATABLE` flag to handle `--foo`/`--no-foo` options
* Add the `Command::$defaultDescription` static property and the `description` attribute
on the `console.command` tag to allow the `list` command to instantiate commands lazily
+ * Add option `--short` to the `list` command
5.2.0
-----
diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php
index 284ddb5fea53a..6759dd305d725 100644
--- a/src/Symfony/Component/Console/Command/ListCommand.php
+++ b/src/Symfony/Component/Console/Command/ListCommand.php
@@ -35,6 +35,7 @@ protected function configure()
new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
+ new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'),
])
->setDescription('Lists commands')
->setHelp(<<<'EOF'
@@ -68,6 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'format' => $input->getOption('format'),
'raw_text' => $input->getOption('raw'),
'namespace' => $input->getArgument('namespace'),
+ 'short' => $input->getOption('short'),
]);
return 0;
diff --git a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
index be4673e30472c..1d2865941a0db 100644
--- a/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
+++ b/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php
@@ -58,7 +58,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o
*/
protected function describeCommand(Command $command, array $options = [])
{
- $this->writeData($this->getCommandData($command), $options);
+ $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options);
}
/**
@@ -71,7 +71,7 @@ protected function describeApplication(Application $application, array $options
$commands = [];
foreach ($description->getCommands() as $command) {
- $commands[] = $this->getCommandData($command);
+ $commands[] = $this->getCommandData($command, $options['short'] ?? false);
}
$data = [];
@@ -153,17 +153,29 @@ private function getInputDefinitionData(InputDefinition $definition): array
return ['arguments' => $inputArguments, 'options' => $inputOptions];
}
- private function getCommandData(Command $command): array
+ private function getCommandData(Command $command, bool $short = false): array
{
- $command->mergeApplicationDefinition(false);
-
- return [
+ $data = [
'name' => $command->getName(),
- 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()),
'description' => $command->getDescription(),
- 'help' => $command->getProcessedHelp(),
- 'definition' => $this->getInputDefinitionData($command->getDefinition()),
- 'hidden' => $command->isHidden(),
];
+
+ if ($short) {
+ $data += [
+ 'usage' => $command->getAliases(),
+ ];
+ } else {
+ $command->mergeApplicationDefinition(false);
+
+ $data += [
+ 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()),
+ 'help' => $command->getProcessedHelp(),
+ 'definition' => $this->getInputDefinitionData($command->getDefinition()),
+ ];
+ }
+
+ $data['hidden'] = $command->isHidden();
+
+ return $data;
}
}
diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php
index db09d8c59477f..db1fe20763ab4 100644
--- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php
+++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php
@@ -122,6 +122,20 @@ protected function describeInputDefinition(InputDefinition $definition, array $o
*/
protected function describeCommand(Command $command, array $options = [])
{
+ if ($options['short'] ?? false) {
+ $this->write(
+ '`'.$command->getName()."`\n"
+ .str_repeat('-', Helper::strlen($command->getName()) + 2)."\n\n"
+ .($command->getDescription() ? $command->getDescription()."\n\n" : '')
+ .'### Usage'."\n\n"
+ .array_reduce($command->getAliases(), function ($carry, $usage) {
+ return $carry.'* `'.$usage.'`'."\n";
+ })
+ );
+
+ return;
+ }
+
$command->mergeApplicationDefinition(false);
$this->write(
@@ -171,7 +185,7 @@ protected function describeApplication(Application $application, array $options
foreach ($description->getCommands() as $command) {
$this->write("\n\n");
- if (null !== $describeCommand = $this->describeCommand($command)) {
+ if (null !== $describeCommand = $this->describeCommand($command, $options)) {
$this->write($describeCommand);
}
}
diff --git a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php
index 86710072be2af..9bf9ea2b14120 100644
--- a/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php
+++ b/src/Symfony/Component/Console/Descriptor/XmlDescriptor.php
@@ -44,36 +44,42 @@ public function getInputDefinitionDocument(InputDefinition $definition): \DOMDoc
return $dom;
}
- public function getCommandDocument(Command $command): \DOMDocument
+ public function getCommandDocument(Command $command, bool $short = false): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($commandXML = $dom->createElement('command'));
- $command->mergeApplicationDefinition(false);
-
$commandXML->setAttribute('id', $command->getName());
$commandXML->setAttribute('name', $command->getName());
$commandXML->setAttribute('hidden', $command->isHidden() ? 1 : 0);
$commandXML->appendChild($usagesXML = $dom->createElement('usages'));
- foreach (array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()) as $usage) {
- $usagesXML->appendChild($dom->createElement('usage', $usage));
- }
-
$commandXML->appendChild($descriptionXML = $dom->createElement('description'));
$descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
- $commandXML->appendChild($helpXML = $dom->createElement('help'));
- $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
+ if ($short) {
+ foreach ($command->getAliases() as $usage) {
+ $usagesXML->appendChild($dom->createElement('usage', $usage));
+ }
+ } else {
+ $command->mergeApplicationDefinition(false);
- $definitionXML = $this->getInputDefinitionDocument($command->getDefinition());
- $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
+ foreach (array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()) as $usage) {
+ $usagesXML->appendChild($dom->createElement('usage', $usage));
+ }
+
+ $commandXML->appendChild($helpXML = $dom->createElement('help'));
+ $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
+
+ $definitionXML = $this->getInputDefinitionDocument($command->getDefinition());
+ $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
+ }
return $dom;
}
- public function getApplicationDocument(Application $application, string $namespace = null): \DOMDocument
+ public function getApplicationDocument(Application $application, string $namespace = null, bool $short = false): \DOMDocument
{
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom->appendChild($rootXml = $dom->createElement('symfony'));
@@ -94,7 +100,7 @@ public function getApplicationDocument(Application $application, string $namespa
}
foreach ($description->getCommands() as $command) {
- $this->appendDocument($commandsXML, $this->getCommandDocument($command));
+ $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short));
}
if (!$namespace) {
@@ -143,7 +149,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o
*/
protected function describeCommand(Command $command, array $options = [])
{
- $this->writeDocument($this->getCommandDocument($command));
+ $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false));
}
/**
@@ -151,7 +157,7 @@ protected function describeCommand(Command $command, array $options = [])
*/
protected function describeApplication(Application $application, array $options = [])
{
- $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null));
+ $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false));
}
/**
diff --git a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php
index 5b25550a6d8ec..4576170a980c6 100644
--- a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php
+++ b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php
@@ -65,7 +65,7 @@ public function testExecuteForApplicationCommandWithXmlOption()
$application = new Application();
$commandTester = new CommandTester($application->get('help'));
$commandTester->execute(['command_name' => 'list', '--format' => 'xml']);
- $this->assertStringContainsString('list [--raw] [--format FORMAT] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
+ $this->assertStringContainsString('list [--raw] [--format FORMAT] [--short] [--] [<namespace>]', $commandTester->getDisplay(), '->execute() returns a text help for the given command');
$this->assertStringContainsString('getDisplay(), '->execute() returns an XML help text if --format=xml is passed');
}
}
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_1.json b/src/Symfony/Component/Console/Tests/Fixtures/application_1.json
index 9e9cf1b52c3a0..b94cf05d2e1b7 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_1.json
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_1.json
@@ -107,7 +107,7 @@
"name": "list",
"hidden": false,
"usage": [
- "list [--raw] [--format FORMAT] [--] []"
+ "list [--raw] [--format FORMAT] [--short] [--] []"
],
"description": "Lists commands",
"help": "The list<\/info> command lists all commands:\n\n app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n app\/console list test<\/info>\n\nYou can also output the information in other formats by using the --format<\/comment> option:\n\n app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n app\/console list --raw<\/info>",
@@ -202,6 +202,15 @@
"is_multiple": false,
"description": "Do not ask any interactive question",
"default": false
+ },
+ "short": {
+ "name": "--short",
+ "shortcut": "",
+ "accept_value": false,
+ "is_value_required": false,
+ "is_multiple": false,
+ "description": "To skip describing commands' arguments",
+ "default": false
}
}
}
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_1.md b/src/Symfony/Component/Console/Tests/Fixtures/application_1.md
index 990f750f5b04a..163d68ff66fbf 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_1.md
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_1.md
@@ -122,7 +122,7 @@ Lists commands
### Usage
-* `list [--raw] [--format FORMAT] [--] []`
+* `list [--raw] [--format FORMAT] [--short] [--] []`
The list command lists all commands:
@@ -172,6 +172,16 @@ The output format (txt, xml, json, or md)
* Is negatable: no
* Default: `'txt'`
+#### `--short`
+
+To skip describing commands' arguments
+
+* Accept value: no
+* Is value required: no
+* Is multiple: no
+* Is negatable: no
+* Default: `false`
+
#### `--help|-h`
Display help for the given command. When no command is given display help for the list command
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_1.xml b/src/Symfony/Component/Console/Tests/Fixtures/application_1.xml
index 313b0d1cc3b5d..5aa8e5a876a7d 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_1.xml
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_1.xml
@@ -58,7 +58,7 @@
- list [--raw] [--format FORMAT] [--] [<namespace>]
+ list [--raw] [--format FORMAT] [--short] [--] [<namespace>]
Lists commands
The <info>list</info> command lists all commands:
@@ -92,6 +92,9 @@
txt
+
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.json b/src/Symfony/Component/Console/Tests/Fixtures/application_2.json
index 4b6d85c2bcfe5..4969191142f31 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.json
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.json
@@ -111,7 +111,7 @@
"name": "list",
"hidden": false,
"usage": [
- "list [--raw] [--format FORMAT] [--] []"
+ "list [--raw] [--format FORMAT] [--short] [--] []"
],
"description": "Lists commands",
"help": "The list<\/info> command lists all commands:\n\n app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n app\/console list test<\/info>\n\nYou can also output the information in other formats by using the --format<\/comment> option:\n\n app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n app\/console list --raw<\/info>",
@@ -206,6 +206,15 @@
"is_multiple": false,
"description": "Do not ask any interactive question",
"default": false
+ },
+ "short": {
+ "name": "--short",
+ "shortcut": "",
+ "accept_value": false,
+ "is_value_required": false,
+ "is_multiple": false,
+ "description": "To skip describing commands' arguments",
+ "default": false
}
}
}
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.md b/src/Symfony/Component/Console/Tests/Fixtures/application_2.md
index 5d453df997cb5..eb23fa80c9315 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.md
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.md
@@ -135,7 +135,7 @@ Lists commands
### Usage
-* `list [--raw] [--format FORMAT] [--] []`
+* `list [--raw] [--format FORMAT] [--short] [--] []`
The list command lists all commands:
@@ -185,6 +185,16 @@ The output format (txt, xml, json, or md)
* Is negatable: no
* Default: `'txt'`
+#### `--short`
+
+To skip describing commands' arguments
+
+* Accept value: no
+* Is value required: no
+* Is multiple: no
+* Is negatable: no
+* Default: `false`
+
#### `--help|-h`
Display help for the given command. When no command is given display help for the list command
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml b/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml
index e745ddd0d637e..0a523a6565c9d 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_2.xml
@@ -58,7 +58,7 @@
- list [--raw] [--format FORMAT] [--] [<namespace>]
+ list [--raw] [--format FORMAT] [--short] [--] [<namespace>]
Lists commands
The <info>list</info> command lists all commands:
@@ -92,6 +92,9 @@
txt
+
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md
index d7305b9a3e713..90d42c0a61d57 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_mbstring.md
@@ -126,7 +126,7 @@ Lists commands
### Usage
-* `list [--raw] [--format FORMAT] [--] []`
+* `list [--raw] [--format FORMAT] [--short] [--] []`
The list command lists all commands:
@@ -176,6 +176,16 @@ The output format (txt, xml, json, or md)
* Is negatable: no
* Default: `'txt'`
+#### `--short`
+
+To skip describing commands' arguments
+
+* Accept value: no
+* Is value required: no
+* Is multiple: no
+* Is negatable: no
+* Default: `false`
+
#### `--help|-h`
Display help for the given command. When no command is given display help for the list command
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt
index 932063d730d67..0fc25deee3ce1 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt
@@ -3,5 +3,5 @@
The "--foo" option does not exist.
-list [--raw] [--format FORMAT] [--] []
+list [--raw] [--format FORMAT] [--short] [--] []
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt
index 33a42c3c83818..406f9ee3e8e7a 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt
@@ -10,6 +10,7 @@ Arguments:
Options:
--raw To output raw command list
--format=FORMAT The output format (txt, xml, json, or md) [default: "txt"]
+ --short To skip describing commands' arguments
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_run3.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_run3.txt
index 33a42c3c83818..406f9ee3e8e7a 100644
--- a/src/Symfony/Component/Console/Tests/Fixtures/application_run3.txt
+++ b/src/Symfony/Component/Console/Tests/Fixtures/application_run3.txt
@@ -10,6 +10,7 @@ Arguments:
Options:
--raw To output raw command list
--format=FORMAT The output format (txt, xml, json, or md) [default: "txt"]
+ --short To skip describing commands' arguments
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version