From bc04b497ee5edd9d62577ae260863eaabe7bea55 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 7 Sep 2022 13:30:06 -0500 Subject: [PATCH] fix(help):Be dense on short next line help 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 --- examples/tutorial_builder/02_app_settings.md | 3 --- examples/tutorial_derive/02_app_settings.md | 3 --- src/output/help.rs | 2 +- tests/builder/help.rs | 9 --------- 4 files changed, 1 insertion(+), 16 deletions(-) diff --git a/examples/tutorial_builder/02_app_settings.md b/examples/tutorial_builder/02_app_settings.md index 4e70f645703b..95bce05131cc 100644 --- a/examples/tutorial_builder/02_app_settings.md +++ b/examples/tutorial_builder/02_app_settings.md @@ -7,13 +7,10 @@ Usage: 02_app_settings[EXE] --two --one Options: --two - --one - -h, --help Print help information - -V, --version Print version information diff --git a/examples/tutorial_derive/02_app_settings.md b/examples/tutorial_derive/02_app_settings.md index ee507a61c027..827abe66b1a8 100644 --- a/examples/tutorial_derive/02_app_settings.md +++ b/examples/tutorial_derive/02_app_settings.md @@ -7,13 +7,10 @@ Usage: 02_app_settings_derive[EXE] --two --one Options: --two - --one - -h, --help Print help information - -V, --version Print version information diff --git a/src/output/help.rs b/src/output/help.rs index edc09cf8f181..68476e1c17ff 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -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"); } } diff --git a/tests/builder/help.rs b/tests/builder/help.rs index 44ee1a60c08c..c1b995599528 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -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 "; @@ -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 "; @@ -743,7 +737,6 @@ Options: -h, --help Print help information - -V, --version Print version @@ -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 @@ -1168,7 +1160,6 @@ Usage: ctest Options: -h, --help Print help information - -V, --version Print version information