clap/tests/derive/raw_idents.rs
Ed Page 177511dab1 fix: Deprecate validator / validator_os
`validator_regex` is being ignored for now as I await on a comment
period for #3743
2022-05-25 12:57:11 -05:00

24 lines
473 B
Rust

use clap::Parser;
#[test]
fn raw_idents() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(short, long, value_parser)]
r#type: String,
}
assert_eq!(
Opt {
r#type: "long".into()
},
Opt::try_parse_from(&["test", "--type", "long"]).unwrap()
);
assert_eq!(
Opt {
r#type: "short".into()
},
Opt::try_parse_from(&["test", "-t", "short"]).unwrap()
);
}