You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to implement Canop/clap-help#1 (showing a custom help message for subcommands). Without subcommands I can catch if --help was requested (Parser::try_parse and ErrorKind::DisplayHelp). But with subcommands, I couldn't find a way (without manually reparsing the arguments) to check if help for a subcommand was issued.
Did I miss something?
Describe the solution you'd like
A solution might be to attach the current clap::Command to the clap_builder::error::Error.
Manually adding help flags is tedious and doesn't work if there are required arguments:
#[derive(Parser,Debug)]#[command( name = "subcommand", author, version, about, disable_help_subcommand = true, disable_help_flag = true)]structArgs{/// Print help#[arg(long)]help:bool,/// A subcommand#[command(subcommand)]pubcommand:Option<Subcmd>,}#[derive(Subcommand,Clone,Debug)]enumSubcmd{/// Some info for A#[clap(disable_help_flag = true)]A{/// Print help#[arg(long)]help:bool,},/// Some info for B#[clap(disable_help_flag = true)]B{/// Print help#[arg(long)]help:bool,/// An argx:u8,},}
For example, this does not work:
> cargo run -- -- b --help
error: the following required arguments were not provided:
<X>
Usage: subcommands b --help <X>
Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Please complete the following tasks
Clap Version
4.5.19
Describe your use case
I'm currently trying to implement Canop/clap-help#1 (showing a custom help message for subcommands). Without subcommands I can catch if
--help
was requested (Parser::try_parse
andErrorKind::DisplayHelp
). But with subcommands, I couldn't find a way (without manually reparsing the arguments) to check if help for a subcommand was issued.Did I miss something?
Describe the solution you'd like
A solution might be to attach the current
clap::Command
to theclap_builder::error::Error
.Manually adding help flags is tedious and doesn't work if there are required arguments:
For example, this does not work:
Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: