Skip to content

Commit

Permalink
fix(help): Don't infer long help from subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 17, 2021
1 parent 27893cf commit 318b785
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,12 @@ impl<'help, 'app> Parser<'help, 'app> {
|| v.is_set(ArgSettings::HiddenShortHelp)
};

// Subcommands aren't checked because we prefer short help for them, deferring to
// `cmd subcmd --help` for more.
self.app.long_about.is_some()
|| self.app.before_long_help.is_some()
|| self.app.after_long_help.is_some()
|| self.app.args.args().any(should_long)
|| self.app.subcommands.iter().any(|s| s.long_about.is_some())
}

fn parse_long_arg(
Expand Down
11 changes: 4 additions & 7 deletions tests/builder/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,11 @@ USAGE:
about-in-subcommands-list [SUBCOMMAND]
OPTIONS:
-h, --help
Print help information
-h, --help Print help information
SUBCOMMANDS:
help
Print this message or the help of the given subcommand(s)
sub
short about sub
help Print this message or the help of the given subcommand(s)
sub short about sub
";

fn setup() -> App<'static> {
Expand Down Expand Up @@ -2281,7 +2278,7 @@ fn option_usage_order() {
}

#[test]
fn about_in_subcommands_list() {
fn prefer_about_over_long_about_in_subcommands_list() {
let app = App::new("about-in-subcommands-list").subcommand(
App::new("sub")
.long_about("long about sub")
Expand Down

0 comments on commit 318b785

Please sign in to comment.