This is the code (I'm using clap 3.2.20):
pub fn main() {
let m = Command::new("foo")
.arg(
Arg::new("bar")
.long("bar")
.required(false)
.action(ArgAction::SetTrue)
)
.get_matches();
if m.contains_id("bar") {
println!("Boom!");
}
}
It prints Boom!
either I provide --bar
option or not. Why and how to fix?