mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 23:02:31 +00:00
392effe319
This PR switches the Arg::Short macro to take a character instead of a string. It removes the hacky code in the Method to_token method and implements the logic for Short when parsing the clap derive arguments. Fixes #1815.
32 lines
639 B
Rust
32 lines
639 B
Rust
mod utils;
|
|
|
|
use clap::Clap;
|
|
use utils::*;
|
|
|
|
#[test]
|
|
fn explicit_short_long_no_rename() {
|
|
#[derive(Clap, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[clap(short = '.', long = ".foo")]
|
|
foo: Vec<String>,
|
|
}
|
|
|
|
assert_eq!(
|
|
Opt {
|
|
foo: vec!["short".into(), "long".into()]
|
|
},
|
|
Opt::parse_from(&["test", "-.", "short", "--.foo", "long"])
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn explicit_name_no_rename() {
|
|
#[derive(Clap, PartialEq, Debug)]
|
|
struct Opt {
|
|
#[clap(name = ".options")]
|
|
foo: Vec<String>,
|
|
}
|
|
|
|
let help = get_long_help::<Opt>();
|
|
assert!(help.contains("[.options]..."))
|
|
}
|