mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
test(derive): Port structopt flatten coverage
https://github.com/TeXitoi/structopt/pull/414 was ported in
a95195874
but the test was less exhaustive. This updates our test to
match structopt's latest version of the test.
This is a part of #2809
This commit is contained in:
parent
00f7fe5472
commit
f681e46414
1 changed files with 18 additions and 10 deletions
|
@ -155,21 +155,29 @@ fn update_subcommands_with_flatten() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn flatten_with_doc_comment() {
|
fn flatten_with_doc_comment() {
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, PartialEq, Debug)]
|
||||||
struct DaemonOpts {
|
struct Common {
|
||||||
#[clap(short)]
|
/// This is an arg. Arg means "argument". Command line argument.
|
||||||
user: String,
|
arg: i32,
|
||||||
#[clap(short)]
|
|
||||||
group: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, PartialEq, Debug)]
|
||||||
#[clap(name = "basic")]
|
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// A very important doc comment I just can't leave out!
|
/// The very important comment that clippy had me put here.
|
||||||
|
/// It knows better.
|
||||||
#[clap(flatten)]
|
#[clap(flatten)]
|
||||||
opts: DaemonOpts,
|
common: Common,
|
||||||
}
|
}
|
||||||
|
assert_eq!(
|
||||||
|
Opt {
|
||||||
|
common: Common { arg: 42 }
|
||||||
|
},
|
||||||
|
Opt::parse_from(&["test", "42"])
|
||||||
|
);
|
||||||
|
|
||||||
|
let help = utils::get_help::<Opt>();
|
||||||
|
assert!(help.contains("This is an arg."));
|
||||||
|
assert!(!help.contains("The very important"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Reference in a new issue