-
I am creating a "help" subcommand that isnt the built-in one, and it then has other subcommands defined to itself mirror all other subcommands in the app (so the same as the built-in help subcommand). however for some reason the usage text is lacking the top-level command/app name. This however doesn't happen with a custom "help" flag (first branch), as in both custom and built-in show the full usage. Here is the matching logic: if matches.contains_id("help") {
let subcommand = if let Some((sub, _)) = matches.remove_subcommand() {
app.find_subcommand(sub).unwrap().clone()
} else {
app
};
help_parse(&mut flags, subcommand);
return Ok(flags);
} else if let Some(help_subcommand_matches) = matches.subcommand_matches("help") {
let subcommand = if let Some(sub) = help_subcommand_matches.subcommand_name() {
app.find_subcommand(sub).unwrap().clone()
} else {
app
};
help_parse(&mut flags, subcommand);
return Ok(flags);
} for more reference, this is the custom help subcommand definition: Command::new("help")
.disable_version_flag(true)
.disable_help_subcommand(true)
.subcommands(app.get_subcommands().map(|command| {
Command::new(command.get_name().to_owned())
.disable_help_flag(true)
.disable_version_flag(true)
})) what may i be missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Inside of |
Beta Was this translation helpful? Give feedback.
Inside of
if matches.contains_id("help") {
you probably need to addapp.build();