use auto_args::AutoArgs;
#[test]
fn unique_flag() {
#[derive(AutoArgs, PartialEq, Debug)]
struct Opt {
alice: bool,
}
assert!(Opt::help().contains("--alice"));
assert!(Opt::help().contains("Documentation for alice"));
assert_eq!(
Opt { alice: true },
Opt::from_iter(&["", "--alice"]).unwrap()
);
assert_eq!(Opt { alice: false }, Opt::from_iter(&[""]).unwrap());
assert!(Opt::from_iter(&["", "--bob"]).is_err());
}
#[test]
fn flag_with_underscores() {
#[derive(AutoArgs, PartialEq, Debug)]
struct Opt {
this_is_awesome: bool,
}
println!("{}", Opt::help());
assert!(Opt::help().contains("--this-is-awesome"));
assert!(Opt::help().contains("Documentation for awesomeness"));
assert_eq!(
Opt {
this_is_awesome: true
},
Opt::from_iter(&["", "--this-is-awesome"]).unwrap()
);
assert_eq!(
Opt {
this_is_awesome: false
},
Opt::from_iter(&[""]).unwrap()
);
assert!(Opt::from_iter(&["", "--bob"]).is_err());
}