Skip to content

Commit 72b94b8

Browse files
committed
minor #38347 [Console] Improve description for the help flag. (rodrigoaguilera)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [Console] Improve description for the help flag. | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | no | License | MIT I am currently trying to improve a CLI tool called `robo` (https://robo.li) that relies heavily on the console component. First thing I did was running it without any argument like `./robo` to find the description for the help flag `-h` or `--help` "Display this help message" This is typical for any CLI tool out there except that when I run `./robo --help` I get the help for the `list` command (same output as `robo help list`). One of the options I considered was to fix this behavior by showing the same output when no command is given disregarding the help flag (just for the case of no command given) but I actually like how symfony console handles the help flag. I think it needs a clarification for the description given so I changed it to: > Display help for the given command. When no command is given display help for the list command Which is more descriptive about what actually happens in the code when that flag is given. Specially the "this" word can be a little confusing. Commits ------- c451c48 [Console] Improve description for the help flag.
2 parents af8ad34 + c451c48 commit 72b94b8

18 files changed

+37
-38
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,7 @@ protected function getDefaultInputDefinition()
10201020
{
10211021
return new InputDefinition([
10221022
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
1023-
1024-
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
1023+
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the <info>'.$this->defaultCommand.'</info> command'),
10251024
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
10261025
new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
10271026
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),

src/Symfony/Component/Console/Tests/Command/ListCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testExecuteListsCommandsOrder()
7777
command [options] [arguments]
7878
7979
Options:
80-
-h, --help Display this help message
80+
-h, --help Display help for the given command. When no command is given display help for the list command
8181
-q, --quiet Do not output any message
8282
-V, --version Display this application version
8383
--ansi Force ANSI output

src/Symfony/Component/Console/Tests/Fixtures/application_1.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"accept_value": false,
4444
"is_value_required": false,
4545
"is_multiple": false,
46-
"description": "Display this help message",
46+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
4747
"default": false
4848
},
4949
"quiet": {
@@ -146,7 +146,7 @@
146146
"accept_value": false,
147147
"is_value_required": false,
148148
"is_multiple": false,
149-
"description": "Display this help message",
149+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
150150
"default": false
151151
},
152152
"quiet": {

src/Symfony/Component/Console/Tests/Fixtures/application_1.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ To output raw command help
5555

5656
#### `--help|-h`
5757

58-
Display this help message
58+
Display help for the given command. When no command is given display help for the list command
5959

6060
* Accept value: no
6161
* Is value required: no
@@ -173,7 +173,7 @@ The output format (txt, xml, json, or md)
173173

174174
#### `--help|-h`
175175

176-
Display this help message
176+
Display help for the given command. When no command is given display help for the list command
177177

178178
* Accept value: no
179179
* Is value required: no

src/Symfony/Component/Console/Tests/Fixtures/application_1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Console Tool
44
command [options] [arguments]
55

66
<comment>Options:</comment>
7-
<info>-h, --help</info> Display this help message
7+
<info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command
88
<info>-q, --quiet</info> Do not output any message
99
<info>-V, --version</info> Display this application version
1010
<info> --ansi</info> Force ANSI output

src/Symfony/Component/Console/Tests/Fixtures/application_1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<description>To output raw command help</description>
3535
</option>
3636
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
37-
<description>Display this help message</description>
37+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
3838
</option>
3939
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
4040
<description>Do not output any message</description>
@@ -93,7 +93,7 @@
9393
</defaults>
9494
</option>
9595
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
96-
<description>Display this help message</description>
96+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
9797
</option>
9898
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
9999
<description>Do not output any message</description>

src/Symfony/Component/Console/Tests/Fixtures/application_2.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"accept_value": false,
4848
"is_value_required": false,
4949
"is_multiple": false,
50-
"description": "Display this help message",
50+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
5151
"default": false
5252
},
5353
"quiet": {
@@ -150,7 +150,7 @@
150150
"accept_value": false,
151151
"is_value_required": false,
152152
"is_multiple": false,
153-
"description": "Display this help message",
153+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
154154
"default": false
155155
},
156156
"quiet": {
@@ -229,7 +229,7 @@
229229
"accept_value": false,
230230
"is_value_required": false,
231231
"is_multiple": false,
232-
"description": "Display this help message",
232+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
233233
"default": false
234234
},
235235
"quiet": {
@@ -325,7 +325,7 @@
325325
"accept_value": false,
326326
"is_value_required": false,
327327
"is_multiple": false,
328-
"description": "Display this help message",
328+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
329329
"default": false
330330
},
331331
"quiet": {
@@ -402,7 +402,7 @@
402402
"accept_value": false,
403403
"is_value_required": false,
404404
"is_multiple": false,
405-
"description": "Display this help message",
405+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
406406
"default": false
407407
},
408408
"quiet": {
@@ -481,7 +481,7 @@
481481
"accept_value": false,
482482
"is_value_required": false,
483483
"is_multiple": false,
484-
"description": "Display this help message",
484+
"description": "Display help for the given command. When no command is given display help for the <info>list</info> command",
485485
"default": false
486486
},
487487
"quiet": {

src/Symfony/Component/Console/Tests/Fixtures/application_2.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ To output raw command help
6868

6969
#### `--help|-h`
7070

71-
Display this help message
71+
Display help for the given command. When no command is given display help for the list command
7272

7373
* Accept value: no
7474
* Is value required: no
@@ -186,7 +186,7 @@ The output format (txt, xml, json, or md)
186186

187187
#### `--help|-h`
188188

189-
Display this help message
189+
Display help for the given command. When no command is given display help for the list command
190190

191191
* Accept value: no
192192
* Is value required: no
@@ -264,7 +264,7 @@ command 1 help
264264

265265
#### `--help|-h`
266266

267-
Display this help message
267+
Display help for the given command. When no command is given display help for the list command
268268

269269
* Accept value: no
270270
* Is value required: no
@@ -357,7 +357,7 @@ command 2 help
357357

358358
#### `--help|-h`
359359

360-
Display this help message
360+
Display help for the given command. When no command is given display help for the list command
361361

362362
* Accept value: no
363363
* Is value required: no
@@ -432,7 +432,7 @@ Do not ask any interactive question
432432

433433
#### `--help|-h`
434434

435-
Display this help message
435+
Display help for the given command. When no command is given display help for the list command
436436

437437
* Accept value: no
438438
* Is value required: no

src/Symfony/Component/Console/Tests/Fixtures/application_2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ My Symfony application <info>v1.0</info>
44
command [options] [arguments]
55

66
<comment>Options:</comment>
7-
<info>-h, --help</info> Display this help message
7+
<info>-h, --help</info> Display help for the given command. When no command is given display help for the <info>list</info> command
88
<info>-q, --quiet</info> Do not output any message
99
<info>-V, --version</info> Display this application version
1010
<info> --ansi</info> Force ANSI output

src/Symfony/Component/Console/Tests/Fixtures/application_2.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<description>To output raw command help</description>
3535
</option>
3636
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
37-
<description>Display this help message</description>
37+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
3838
</option>
3939
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
4040
<description>Do not output any message</description>
@@ -93,7 +93,7 @@
9393
</defaults>
9494
</option>
9595
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
96-
<description>Display this help message</description>
96+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
9797
</option>
9898
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
9999
<description>Do not output any message</description>
@@ -126,7 +126,7 @@
126126
<arguments/>
127127
<options>
128128
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
129-
<description>Display this help message</description>
129+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
130130
</option>
131131
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
132132
<description>Do not output any message</description>
@@ -167,7 +167,7 @@
167167
<description></description>
168168
</option>
169169
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
170-
<description>Display this help message</description>
170+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
171171
</option>
172172
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
173173
<description>Do not output any message</description>
@@ -198,7 +198,7 @@
198198
<arguments/>
199199
<options>
200200
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
201-
<description>Display this help message</description>
201+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
202202
</option>
203203
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
204204
<description>Do not output any message</description>
@@ -231,7 +231,7 @@
231231
<arguments/>
232232
<options>
233233
<option name="--help" shortcut="-h" accept_value="0" is_value_required="0" is_multiple="0">
234-
<description>Display this help message</description>
234+
<description>Display help for the given command. When no command is given display help for the &lt;info&gt;list&lt;/info&gt; command</description>
235235
</option>
236236
<option name="--quiet" shortcut="-q" accept_value="0" is_value_required="0" is_multiple="0">
237237
<description>Do not output any message</description>

0 commit comments

Comments
 (0)