Skip to content

Commit

Permalink
fix(help): Use right about when flattening
Browse files Browse the repository at this point in the history
Fixes #5226
  • Loading branch information
epage committed Nov 27, 2023
1 parent e9194b5 commit 22130e3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
4 changes: 2 additions & 2 deletions clap_builder/src/output/help_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,9 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
*first = false;

let heading = subcommand.get_usage_name_fallback();
let about = cmd
let about = subcommand
.get_about()
.or_else(|| cmd.get_long_about())
.or_else(|| subcommand.get_long_about())
.unwrap_or_default();

let _ = write!(
Expand Down
1 change: 1 addition & 0 deletions examples/git-derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ git-derive[EXE] stash apply:
[STASH]

git-derive[EXE] stash help:
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)

$ git-derive stash push -h
Expand Down
1 change: 1 addition & 0 deletions examples/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ git[EXE] stash apply:
[STASH]

git[EXE] stash help:
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)

$ git stash push -h
Expand Down
68 changes: 34 additions & 34 deletions tests/builder/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2963,12 +2963,12 @@ Options:
-h, --help Print help
parent test:
parent command
test command
--child <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -2997,12 +2997,12 @@ Options:
-h, --help Print help (see more with '--help')
parent test:
parent command
test command
--child <child> foo
-h, --help Print help (see more with '--help')
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3040,15 +3040,15 @@ Options:
Print help (see a summary with '-h')
parent test:
parent command
test command
--child <child>
bar
-h, --help
Print help (see a summary with '-h')
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]...
Print help for the subcommand(s)
";
Expand Down Expand Up @@ -3087,15 +3087,15 @@ Options:
Print help (see a summary with '-h')
parent test:
parent command
test command
--child <child>
bar
-h, --help
Print help (see a summary with '-h')
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]...
Print help for the subcommand(s)
";
Expand Down Expand Up @@ -3131,12 +3131,12 @@ Options:
-h, --help Print help
parent test:
parent command
test command
--child <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3165,12 +3165,12 @@ Options:
-h, --help Print help
parent --parent <parent> test:
parent command
test command
--child <child>
-h, --help Print help
parent --parent <parent> help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3199,12 +3199,12 @@ Options:
-h, --help Print help
parent test:
parent command
test command
--child <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3251,12 +3251,12 @@ Options:
-h, --help Print help
parent test:
parent command
test command
--child <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3286,12 +3286,12 @@ Options:
-h, --help Print help
parent test:
parent command
test command
--child <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3332,60 +3332,60 @@ Options:
-h, --help Print help
parent child1:
parent command
child1 command
--child1 <child>
-h, --help Print help
parent child1 grandchild1:
child1 command
grandchild1 command
--grandchild1 <grandchild>
-h, --help Print help
parent child1 grandchild1 greatgrandchild1:
grandchild1 command
greatgrandchild1 command
--greatgrandchild1 <greatgrandchild>
-h, --help Print help
parent child1 grandchild1 greatgrandchild2:
grandchild1 command
greatgrandchild2 command
--greatgrandchild2 <greatgrandchild>
-h, --help Print help
parent child1 grandchild1 greatgrandchild3:
grandchild1 command
greatgrandchild3 command
--greatgrandchild3 <greatgrandchild>
-h, --help Print help
parent child1 grandchild1 help:
grandchild1 command
Print this message or the help of the given subcommand(s)
parent child1 grandchild2:
child1 command
grandchild2 command
--grandchild2 <grandchild>
-h, --help Print help
parent child1 grandchild3:
child1 command
grandchild3 command
--grandchild3 <grandchild>
-h, --help Print help
parent child1 help:
child1 command
Print this message or the help of the given subcommand(s)
parent child2:
parent command
child2 command
--child2 <child>
-h, --help Print help
parent child3:
parent command
child3 command
--child3 <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down Expand Up @@ -3458,22 +3458,22 @@ Options:
-h, --help Print help
parent child1:
parent command
child1 command
--child1 <child>
-h, --help Print help
parent child2:
parent command
child2 command
--child2 <child>
-h, --help Print help
parent child3:
parent command
child3 command
--child3 <child>
-h, --help Print help
parent help:
parent command
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
Expand Down

0 comments on commit 22130e3

Please sign in to comment.