-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e4fa6f
commit b5907e8
Showing
10 changed files
with
153 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use structopt::StructOpt; | ||
|
||
#[test] | ||
fn explicit_short_long_no_rename() { | ||
#[derive(StructOpt, PartialEq, Debug)] | ||
struct Opt { | ||
#[structopt(short = ".", long = ".foo")] | ||
foo: Vec<String>, | ||
} | ||
|
||
assert_eq!( | ||
Opt { | ||
foo: vec!["short".into(), "long".into()] | ||
}, | ||
Opt::from_iter(&["test", "-.", "short", "--.foo", "long"]) | ||
); | ||
} | ||
|
||
#[test] | ||
fn explicit_name_no_rename() { | ||
#[derive(StructOpt, PartialEq, Debug)] | ||
struct Opt { | ||
#[structopt(name = ".options")] | ||
foo: Vec<String>, | ||
} | ||
|
||
let mut output = Vec::new(); | ||
Opt::clap().write_long_help(&mut output).unwrap(); | ||
let help = String::from_utf8(output).unwrap(); | ||
|
||
assert!(help.contains("[.options]...")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use structopt::StructOpt; | ||
|
||
#[test] | ||
fn raw_idents() { | ||
#[derive(StructOpt, Debug, PartialEq)] | ||
struct Opt { | ||
#[structopt(short, long)] | ||
r#type: Vec<String>, | ||
} | ||
|
||
assert_eq!( | ||
Opt { | ||
r#type: vec!["long".into(), "short".into()] | ||
}, | ||
Opt::from_iter(&["test", "--type", "long", "-t", "short"]) | ||
); | ||
} |
Oops, something went wrong.