fix(help): Hide subcommands in flattened usage

This commit is contained in:
Ed Page 2023-11-27 10:43:16 -06:00
parent b6561983a0
commit a9322cabf3
2 changed files with 5 additions and 4 deletions

View file

@ -113,7 +113,11 @@ impl<'cmd> Usage<'cmd> {
}
let mut cmd = self.cmd.clone();
cmd.build();
for (i, sub) in cmd.get_subcommands().enumerate() {
for (i, sub) in cmd
.get_subcommands()
.filter(|c| !c.is_hide_set())
.enumerate()
{
if i != 0 {
styled.trim_end();
let _ = write!(styled, "{}", USAGE_SEP);

View file

@ -3314,7 +3314,6 @@ fn flatten_single_hidden_command() {
parent command
Usage: parent [OPTIONS]
parent child1 [OPTIONS]
parent help [COMMAND]...
Options:
@ -3346,7 +3345,6 @@ parent command
Usage: parent [OPTIONS]
parent child1 [OPTIONS]
parent child2 [OPTIONS]
parent child3 [OPTIONS]
parent help [COMMAND]...
Options:
@ -3406,7 +3404,6 @@ Usage: parent [OPTIONS]
parent child1 grandchild3 [OPTIONS]
parent child1 help [COMMAND]
parent child2 [OPTIONS]
parent child3 [OPTIONS] [COMMAND]
parent help [COMMAND]...
Options: