Skip to content

Commit

Permalink
fix(help):Be dense on short next line help
Browse files Browse the repository at this point in the history
If short help is too long for the terminal, clap will automatically
switch to next line help.  As part of next line help for longs, we add a
blank line between args.  This helps make the args clearer when dealing
with multiple paragraphs.  However, its not as much needed for short and
subcommands (always short), so now short matches subcommands.

This was inspired by #3300 and a part of #4132
  • Loading branch information
epage committed Sep 7, 2022
1 parent 69dd145 commit bc04b49
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 16 deletions.
3 changes: 0 additions & 3 deletions examples/tutorial_builder/02_app_settings.md
Expand Up @@ -7,13 +7,10 @@ Usage: 02_app_settings[EXE] --two <VALUE> --one <VALUE>
Options:
--two <VALUE>

--one <VALUE>

-h, --help
Print help information

-V, --version
Print version information

Expand Down
3 changes: 0 additions & 3 deletions examples/tutorial_derive/02_app_settings.md
Expand Up @@ -7,13 +7,10 @@ Usage: 02_app_settings_derive[EXE] --two <TWO> --one <ONE>
Options:
--two <TWO>

--one <ONE>

-h, --help
Print help information

-V, --version
Print version information

Expand Down
2 changes: 1 addition & 1 deletion src/output/help.rs
Expand Up @@ -438,7 +438,7 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> {
for (i, (_, arg)) in ord_v.iter().enumerate() {
if i != 0 {
self.none("\n");
if next_line_help {
if next_line_help && self.use_long {
self.none("\n");
}
}
Expand Down
9 changes: 0 additions & 9 deletions tests/builder/help.rs
Expand Up @@ -355,17 +355,13 @@ Options:
-a, --all
Also do versioning for private crates (will not be
published)
--exact
Specify inter dependency version numbers exactly with
`=`
--no-git-commit
Do not commit version changes
--no-git-push
Do not push generated commit and tags to git remote
-h, --help
Print help information
";
Expand Down Expand Up @@ -694,10 +690,8 @@ Options:
les marchés d\'exportation. Le café est
souvent une contribution majeure aux
exportations des régions productrices.
-h, --help
Print help information
-V, --version
Print version information
";
Expand Down Expand Up @@ -743,7 +737,6 @@ Options:
-h, --help
Print help
information
-V, --version
Print
version
Expand Down Expand Up @@ -816,7 +809,6 @@ Options:
that require an
emulator. See
https://github.com/rust-lang/rustup/wiki/Non-host-toolchains
-h, --help
Print help
information
Expand Down Expand Up @@ -1168,7 +1160,6 @@ Usage: ctest
Options:
-h, --help
Print help information
-V, --version
Print version
information
Expand Down

0 comments on commit bc04b49

Please sign in to comment.