-
I wish my boolean setting to be input either as:
What I have come up with is: #[arg(
long,
num_args(0..=1),
default_value_t = true, // (or false)
default_missing_value("true"),
)]
flag: std::primitive::bool, It works the way I expect, but it looks very complicated. Is there a better way? #[arg(long, default_value_t = true, explicit_value_allowed)]
flag: bool, or something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Another way of writing this is #[arg(
long,
num_args(0..=1),
action = clap::builder::ArgAction::Set,
default_value = "false",
default_missing_value = "true",
)]
flag: bool, At the time, there is not a better way. I would not want to provide a way of doing this without an explicit As an alternative, I think if we relax the #[arg(
long,
num_args(0..=1),
)]
flag: bool, |
Beta Was this translation helpful? Give feedback.
#5912 was released in 4.5.30