fix(help): Gloss over globals with flatten

When using globals, people tend to make all of the top-level arguments
global and cascading them through would just bloat the output.
This commit is contained in:
Ed Page 2023-11-09 14:37:09 -06:00
parent 9e5f93d43f
commit c9a7ef06e1
2 changed files with 3 additions and 4 deletions

View file

@ -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);
}

View file

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