Skip to content

Commit

Permalink
fix(help): Gloss over globals with flatten
Browse files Browse the repository at this point in the history
When using globals, people tend to make all of the top-level arguments
global and cascading them through would just bloat the output.
  • Loading branch information
epage committed Nov 9, 2023
1 parent 9e5f93d commit c9a7ef0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clap_builder/src/output/help_template.rs
Expand Up @@ -525,7 +525,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
};
let args = subcommand
.get_arguments()
.filter(|arg| should_show_arg(self.use_long, arg))
.filter(|arg| should_show_arg(self.use_long, arg) && !arg.is_global_set())
.collect::<Vec<_>>();
sub_help.write_args(&args, heading, option_sort_key);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/builder/help.rs
Expand Up @@ -3109,9 +3109,8 @@ Options:
-h, --help Print help
parent test:
--child <child>
--parent <parent>
-h, --help Print help
--child <child>
-h, --help Print help
parent help:
[COMMAND]... Print help for the subcommand(s)
Expand Down

0 comments on commit c9a7ef0

Please sign in to comment.