Merge pull request #3196 from epage/help

fix(help): Don't infer long help from subcommands
This commit is contained in:
Ed Page 2021-12-17 09:54:02 -06:00 committed by GitHub
commit a61a63ac88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View file

@ -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(

View file

@ -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> {
@ -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")