2017-02-28 04:36:11 +00:00
|
|
|
extern crate clap;
|
|
|
|
extern crate regex;
|
|
|
|
|
|
|
|
use clap::{App, Arg, SubCommand};
|
|
|
|
|
|
|
|
include!("../clap-test.rs");
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn borrowed_args() {
|
2018-01-25 04:05:05 +00:00
|
|
|
let arg = Arg::with_name("some")
|
|
|
|
.short("s")
|
|
|
|
.long("some")
|
|
|
|
.help("other help");
|
|
|
|
let arg2 = Arg::with_name("some2")
|
|
|
|
.short("S")
|
|
|
|
.long("some-thing")
|
|
|
|
.help("other help");
|
2017-02-28 04:36:11 +00:00
|
|
|
let result = App::new("sub_command_negate")
|
|
|
|
.arg(Arg::with_name("test").index(1))
|
|
|
|
.arg(&arg)
|
|
|
|
.arg(&arg2)
|
|
|
|
.subcommand(SubCommand::with_name("sub1").arg(&arg))
|
|
|
|
.get_matches_from_safe(vec!["prog"]);
|
|
|
|
assert!(result.is_ok());
|
|
|
|
}
|