diff --git a/clap_builder/src/output/usage.rs b/clap_builder/src/output/usage.rs index 0b2ff3b93c3..6e27b160054 100644 --- a/clap_builder/src/output/usage.rs +++ b/clap_builder/src/output/usage.rs @@ -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); diff --git a/tests/builder/help.rs b/tests/builder/help.rs index a96e8b9630b..562d906c05f 100644 --- a/tests/builder/help.rs +++ b/tests/builder/help.rs @@ -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: