fix(help): Hide 'help' if only flattened subcommand

This commit is contained in:
Ed Page 2023-11-27 10:49:21 -06:00
parent a9322cabf3
commit b13f6d9862
3 changed files with 2 additions and 7 deletions

View file

@ -476,7 +476,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
}
}
}
if flatten {
if subcmds && flatten {
let mut cmd = self.cmd.clone();
cmd.build();
self.write_flat_subcommands(&cmd, &mut first);

View file

@ -103,7 +103,7 @@ impl<'cmd> Usage<'cmd> {
debug!("Usage::write_help_usage");
use std::fmt::Write;
if self.cmd.is_flatten_help_set() {
if self.cmd.has_visible_subcommands() && self.cmd.is_flatten_help_set() {
if !self.cmd.is_subcommand_required_set()
|| self.cmd.is_args_conflicts_with_subcommands_set()
{

View file

@ -3314,15 +3314,10 @@ fn flatten_single_hidden_command() {
parent command
Usage: parent [OPTIONS]
parent help [COMMAND]...
Options:
--parent <parent>
-h, --help Print help
parent help:
Print this message or the help of the given subcommand(s)
[COMMAND]... Print help for the subcommand(s)
";
let cmd = Command::new("parent")
.flatten_help(true)