mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
fix(help): Hide 'help' if only flattened subcommand
This commit is contained in:
parent
a9322cabf3
commit
b13f6d9862
3 changed files with 2 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue