mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
177511dab1
`validator_regex` is being ignored for now as I await on a comment period for #3743
36 lines
761 B
Rust
36 lines
761 B
Rust
use crate::utils;
|
|
|
|
use clap::Parser;
|
|
|
|
#[test]
|
|
fn explicit_short_long_no_rename() {
|
|
#[derive(Parser, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[clap(short = '.', long = ".foo", value_parser)]
|
|
foo: String,
|
|
}
|
|
|
|
assert_eq!(
|
|
Opt { foo: "long".into() },
|
|
Opt::try_parse_from(&["test", "--.foo", "long"]).unwrap()
|
|
);
|
|
|
|
assert_eq!(
|
|
Opt {
|
|
foo: "short".into(),
|
|
},
|
|
Opt::try_parse_from(&["test", "-.", "short"]).unwrap()
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn explicit_name_no_rename() {
|
|
#[derive(Parser, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[clap(name = ".options", value_parser)]
|
|
foo: String,
|
|
}
|
|
|
|
let help = utils::get_long_help::<Opt>();
|
|
assert!(help.contains("<.options>"))
|
|
}
|