-
This may (or may not?) be possible to accomplish by putting all your required arguments into an A minimal example setup: #[derive(clap::Parser)]
struct Args {
required_1: String,
required_2: String,
// How to make this override the required arguments and
// simply print a different help page and exit?
// There doesn't seem to be an `ArgAction` for it.
#[arg(default_value_t=false)]
different_help: bool
}
fn main() {
let _args: Args = clap::Parser::parse();
// Can't check for `_args.different_help` here, since it'll error out
// due to the required arguments being missing.
} Is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
We offer exclusive but that has challenges with the derive API because the struct needs to be populated. You can switch the struct to using Members of a group are exclusive by default. You can also declare groups to conflict with other groups. #2621 would help with some things but could run into #4697. |
Beta Was this translation helpful? Give feedback.
--help
is processed during the parsing process. A particularly important aspect id that this is processed before the struct is populated.We offer exclusive but that has challenges with the derive API because the struct needs to be populated. You can switch the struct to using
Option
fields with explicitrequired = true
to make that work.Members of a group are exclusive by default. You can also declare groups to conflict with other groups. #2621 would help with some things but could run into #4697.