mirror of
https://github.com/clap-rs/clap
synced 2024-11-15 00:57:15 +00:00
a7ed5d012d
The builder function was deprecated in v3 and removed in v4 but the derive masked that, so we're still adapting things but now with a path towards removal.
36 lines
729 B
Rust
36 lines
729 B
Rust
use crate::utils;
|
|
|
|
use clap::Parser;
|
|
|
|
#[test]
|
|
fn explicit_short_long_no_rename() {
|
|
#[derive(Parser, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[arg(short = '.', long = ".foo")]
|
|
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 {
|
|
#[arg(id = ".options")]
|
|
foo: String,
|
|
}
|
|
|
|
let help = utils::get_long_help::<Opt>();
|
|
assert!(help.contains("<.options>"))
|
|
}
|