mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
tests(Usage Parser): moves tests usage parser since that's what it's testing
This commit is contained in:
parent
0bcc712064
commit
816cec8152
3 changed files with 2 additions and 889 deletions
124
tests/flags.rs
124
tests/flags.rs
|
@ -85,127 +85,3 @@ fn short_flag_name_missing() {
|
|||
assert!(a.num_vals.is_none());
|
||||
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_flag() {
|
||||
let _ = App::new("test")
|
||||
.arg(Arg::with_name("test")
|
||||
.short("t")
|
||||
.long("test")
|
||||
.help("testing testing"))
|
||||
.get_matches();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_flag_usage() {
|
||||
let a = Arg::from_usage("[flag] -f 'some help info'");
|
||||
assert_eq!(a.name, "flag");
|
||||
assert_eq!(a.short.unwrap(), 'f');
|
||||
assert!(a.long.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.val_names.is_none());
|
||||
assert!(a.num_vals.is_none());
|
||||
|
||||
let b = Arg::from_usage("[flag] --flag 'some help info'");
|
||||
assert_eq!(b.name, "flag");
|
||||
assert_eq!(b.long.unwrap(), "flag");
|
||||
assert!(b.short.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(a.val_names.is_none());
|
||||
assert!(a.num_vals.is_none());
|
||||
|
||||
let b = Arg::from_usage("--flag 'some help info'");
|
||||
assert_eq!(b.name, "flag");
|
||||
assert_eq!(b.long.unwrap(), "flag");
|
||||
assert!(b.short.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.val_names.is_none());
|
||||
assert!(b.num_vals.is_none());
|
||||
|
||||
let c = Arg::from_usage("[flag] -f --flag 'some help info'");
|
||||
assert_eq!(c.name, "flag");
|
||||
assert_eq!(c.short.unwrap(), 'f');
|
||||
assert_eq!(c.long.unwrap(), "flag");
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(!c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.val_names.is_none());
|
||||
assert!(c.num_vals.is_none());
|
||||
|
||||
let d = Arg::from_usage("[flag] -f... 'some help info'");
|
||||
assert_eq!(d.name, "flag");
|
||||
assert_eq!(d.short.unwrap(), 'f');
|
||||
assert!(d.long.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.val_names.is_none());
|
||||
assert!(d.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("[flag] -f --flag... 'some help info'");
|
||||
assert_eq!(e.name, "flag");
|
||||
assert_eq!(e.long.unwrap(), "flag");
|
||||
assert_eq!(e.short.unwrap(), 'f');
|
||||
assert_eq!(e.help.unwrap(), "some help info");
|
||||
assert!(e.is_set(ArgSettings::Multiple));
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("-f --flag... 'some help info'");
|
||||
assert_eq!(e.name, "flag");
|
||||
assert_eq!(e.long.unwrap(), "flag");
|
||||
assert_eq!(e.short.unwrap(), 'f');
|
||||
assert_eq!(e.help.unwrap(), "some help info");
|
||||
assert!(e.is_set(ArgSettings::Multiple));
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("--flags");
|
||||
assert_eq!(e.name, "flags");
|
||||
assert_eq!(e.long.unwrap(), "flags");
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("--flags...");
|
||||
assert_eq!(e.name, "flags");
|
||||
assert_eq!(e.long.unwrap(), "flags");
|
||||
assert!(e.is_set(ArgSettings::Multiple));
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("[flags] -f");
|
||||
assert_eq!(e.name, "flags");
|
||||
assert_eq!(e.short.unwrap(), 'f');
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("[flags] -f...");
|
||||
assert_eq!(e.name, "flags");
|
||||
assert_eq!(e.short.unwrap(), 'f');
|
||||
assert!(e.is_set(ArgSettings::Multiple));
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let a = Arg::from_usage("-f 'some help info'");
|
||||
assert_eq!(a.name, "f");
|
||||
assert_eq!(a.short.unwrap(), 'f');
|
||||
assert!(a.long.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.val_names.is_none());
|
||||
assert!(a.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("-f");
|
||||
assert_eq!(e.name, "f");
|
||||
assert_eq!(e.short.unwrap(), 'f');
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
|
||||
let e = Arg::from_usage("-f...");
|
||||
assert_eq!(e.name, "f");
|
||||
assert_eq!(e.short.unwrap(), 'f');
|
||||
assert!(e.is_set(ArgSettings::Multiple));
|
||||
assert!(e.val_names.is_none());
|
||||
assert!(e.num_vals.is_none());
|
||||
}
|
||||
|
|
716
tests/opts.rs
716
tests/opts.rs
|
@ -1,6 +1,6 @@
|
|||
extern crate clap;
|
||||
|
||||
use clap::{App, Arg, ArgSettings};
|
||||
use clap::{App, Arg};
|
||||
|
||||
#[test]
|
||||
fn opts_using_short() {
|
||||
|
@ -81,717 +81,3 @@ fn opts_using_mixed2() {
|
|||
assert!(m.is_present("color"));
|
||||
assert_eq!(m.value_of("color").unwrap(), "other");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage0() {
|
||||
// Short only
|
||||
let a = Arg::from_usage("[option] -o [opt] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert!(a.long.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage1() {
|
||||
let b = Arg::from_usage("-o [opt] 'some help info'");
|
||||
assert_eq!(b.name, "o");
|
||||
assert_eq!(b.short.unwrap(), 'o');
|
||||
assert!(b.long.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage2() {
|
||||
let c = Arg::from_usage("<option> -o <opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert!(c.long.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(!c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage3() {
|
||||
let d = Arg::from_usage("-o <opt> 'some help info'");
|
||||
assert_eq!(d.name, "o");
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert!(d.long.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage4() {
|
||||
let a = Arg::from_usage("[option] -o [opt]... 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert!(a.long.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage5() {
|
||||
let a = Arg::from_usage("[option]... -o [opt] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert!(a.long.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage6() {
|
||||
let b = Arg::from_usage("-o [opt]... 'some help info'");
|
||||
assert_eq!(b.name, "o");
|
||||
assert_eq!(b.short.unwrap(), 'o');
|
||||
assert!(b.long.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage7() {
|
||||
let c = Arg::from_usage("<option> -o <opt>... 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert!(c.long.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage8() {
|
||||
let c = Arg::from_usage("<option>... -o <opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert!(c.long.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage9() {
|
||||
let d = Arg::from_usage("-o <opt>... 'some help info'");
|
||||
assert_eq!(d.name, "o");
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert!(d.long.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long1() {
|
||||
let a = Arg::from_usage("[option] --opt [opt] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert!(a.short.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long2() {
|
||||
let b = Arg::from_usage("--opt [option] 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert!(b.short.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long3() {
|
||||
let c = Arg::from_usage("<option> --opt <opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert!(c.short.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(!c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long4() {
|
||||
let d = Arg::from_usage("--opt <option> 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long5() {
|
||||
let a = Arg::from_usage("[option] --opt [opt]... 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert!(a.short.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long6() {
|
||||
let a = Arg::from_usage("[option]... --opt [opt] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert!(a.short.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long7() {
|
||||
let b = Arg::from_usage("--opt [option]... 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert!(b.short.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long8() {
|
||||
let c = Arg::from_usage("<option> --opt <opt>... 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert!(c.short.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long9() {
|
||||
let c = Arg::from_usage("<option>... --opt <opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert!(c.short.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long10() {
|
||||
let d = Arg::from_usage("--opt <option>... 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals1() {
|
||||
let a = Arg::from_usage("[option] --opt=[opt] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert!(a.short.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals2() {
|
||||
let b = Arg::from_usage("--opt=[option] 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert!(b.short.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals3() {
|
||||
let c = Arg::from_usage("<option> --opt=<opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert!(c.short.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(!c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals4() {
|
||||
let d = Arg::from_usage("--opt=<option> 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals5() {
|
||||
let a = Arg::from_usage("[option] --opt=[opt]... 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert!(a.short.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals6() {
|
||||
let a = Arg::from_usage("[option]... --opt=[opt] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert!(a.short.is_none());
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals7() {
|
||||
let b = Arg::from_usage("--opt=[option]... 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert!(b.short.is_none());
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals8() {
|
||||
let c = Arg::from_usage("<option> --opt=<opt>... 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert!(c.short.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals9() {
|
||||
let c = Arg::from_usage("<option>... --opt=<opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert!(c.short.is_none());
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_long_equals10() {
|
||||
let d = Arg::from_usage("--opt=<option>... 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both1() {
|
||||
let a = Arg::from_usage("[option] -o --opt [option] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both2() {
|
||||
let b = Arg::from_usage("-o --opt [option] 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert_eq!(b.short.unwrap(), 'o');
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both3() {
|
||||
let c = Arg::from_usage("<option> -o --opt <opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(!c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both4() {
|
||||
let d = Arg::from_usage("-o --opt <option> 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both5() {
|
||||
let a = Arg::from_usage("[option]... -o --opt [option] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both6() {
|
||||
let b = Arg::from_usage("-o --opt [option]... 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert_eq!(b.short.unwrap(), 'o');
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both7() {
|
||||
let c = Arg::from_usage("<option>... -o --opt <opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both8() {
|
||||
let d = Arg::from_usage("-o --opt <option>... 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals1() {
|
||||
let a = Arg::from_usage("[option] -o --opt=[option] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals2() {
|
||||
let b = Arg::from_usage("-o --opt=[option] 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert_eq!(b.short.unwrap(), 'o');
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals3() {
|
||||
let c = Arg::from_usage("<option> -o --opt=<opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(!c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals4() {
|
||||
let d = Arg::from_usage("-o --opt=<option> 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals5() {
|
||||
let a = Arg::from_usage("[option]... -o --opt=[option] 'some help info'");
|
||||
assert_eq!(a.name, "option");
|
||||
assert_eq!(a.long.unwrap(), "opt");
|
||||
assert_eq!(a.short.unwrap(), 'o');
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(a.is_set(ArgSettings::Multiple));
|
||||
assert!(a.is_set(ArgSettings::TakesValue));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert_eq!(a.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(a.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals6() {
|
||||
let b = Arg::from_usage("-o --opt=[option]... 'some help info'");
|
||||
assert_eq!(b.name, "opt");
|
||||
assert_eq!(b.long.unwrap(), "opt");
|
||||
assert_eq!(b.short.unwrap(), 'o');
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::TakesValue));
|
||||
assert!(!b.is_set(ArgSettings::Required));
|
||||
assert_eq!(b.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(b.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals7() {
|
||||
let c = Arg::from_usage("<option>... -o --opt=<opt> 'some help info'");
|
||||
assert_eq!(c.name, "option");
|
||||
assert_eq!(c.long.unwrap(), "opt");
|
||||
assert_eq!(c.short.unwrap(), 'o');
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(c.is_set(ArgSettings::TakesValue));
|
||||
assert!(c.is_set(ArgSettings::Required));
|
||||
assert_eq!(c.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["opt"]);
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_usage_both_equals8() {
|
||||
let d = Arg::from_usage("-o --opt=<option>... 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["option"]);
|
||||
assert!(d.num_vals.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_with_vals1() {
|
||||
let d = Arg::from_usage("-o <file> <mode> 'some help info'");
|
||||
assert_eq!(d.name, "o");
|
||||
assert!(d.long.is_none());
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["file", "mode"]);
|
||||
assert_eq!(d.num_vals.unwrap(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_with_vals2() {
|
||||
let d = Arg::from_usage("-o <file> <mode>... 'some help info'");
|
||||
assert_eq!(d.name, "o");
|
||||
assert!(d.long.is_none());
|
||||
assert_eq!(d.short.unwrap(), 'o');
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["file", "mode"]);
|
||||
assert_eq!(d.num_vals.unwrap(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_with_vals3() {
|
||||
let d = Arg::from_usage("--opt <file> <mode>... 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["file", "mode"]);
|
||||
assert_eq!(d.num_vals.unwrap(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_with_vals4() {
|
||||
let d = Arg::from_usage("[myopt] --opt <file> <mode> 'some help info'");
|
||||
assert_eq!(d.name, "myopt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(!d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.val_names.unwrap().iter().map(|(_, &v)| v).collect::<Vec<_>>(), ["file", "mode"]);
|
||||
assert_eq!(d.num_vals.unwrap(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_option_with_vals5() {
|
||||
let d = Arg::from_usage("--opt <file> <mode> 'some help info'");
|
||||
assert_eq!(d.name, "opt");
|
||||
assert!(d.short.is_none());
|
||||
assert_eq!(d.long.unwrap(), "opt");
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(!d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::TakesValue));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert_eq!(d.num_vals.unwrap(), 2);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extern crate clap;
|
||||
|
||||
use clap::{App, Arg, ErrorKind, ArgSettings};
|
||||
use clap::{App, Arg, ErrorKind};
|
||||
|
||||
#[test]
|
||||
fn positional() {
|
||||
|
@ -91,52 +91,3 @@ fn create_positional() {
|
|||
.help("testing testing"))
|
||||
.get_matches();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_positional_usage() {
|
||||
let a = Arg::from_usage("[pos] 'some help info'");
|
||||
assert_eq!(a.name, "pos");
|
||||
assert_eq!(a.help.unwrap(), "some help info");
|
||||
assert!(!a.is_set(ArgSettings::Multiple));
|
||||
assert!(!a.is_set(ArgSettings::Required));
|
||||
assert!(a.val_names.is_none());
|
||||
assert!(a.num_vals.is_none());
|
||||
|
||||
let b = Arg::from_usage("<pos> 'some help info'");
|
||||
assert_eq!(b.name, "pos");
|
||||
assert_eq!(b.help.unwrap(), "some help info");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::Required));
|
||||
assert!(b.val_names.is_none());
|
||||
assert!(b.num_vals.is_none());
|
||||
|
||||
let c = Arg::from_usage("[pos]... 'some help info'");
|
||||
assert_eq!(c.name, "pos");
|
||||
assert_eq!(c.help.unwrap(), "some help info");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(!c.is_set(ArgSettings::Required));
|
||||
assert!(c.val_names.is_none());
|
||||
assert!(c.num_vals.is_none());
|
||||
|
||||
let d = Arg::from_usage("<pos>... 'some help info'");
|
||||
assert_eq!(d.name, "pos");
|
||||
assert_eq!(d.help.unwrap(), "some help info");
|
||||
assert!(d.is_set(ArgSettings::Multiple));
|
||||
assert!(d.is_set(ArgSettings::Required));
|
||||
assert!(d.val_names.is_none());
|
||||
assert!(d.num_vals.is_none());
|
||||
|
||||
let b = Arg::from_usage("<pos>");
|
||||
assert_eq!(b.name, "pos");
|
||||
assert!(!b.is_set(ArgSettings::Multiple));
|
||||
assert!(b.is_set(ArgSettings::Required));
|
||||
assert!(b.val_names.is_none());
|
||||
assert!(b.num_vals.is_none());
|
||||
|
||||
let c = Arg::from_usage("[pos]...");
|
||||
assert_eq!(c.name, "pos");
|
||||
assert!(c.is_set(ArgSettings::Multiple));
|
||||
assert!(!c.is_set(ArgSettings::Required));
|
||||
assert!(c.val_names.is_none());
|
||||
assert!(c.num_vals.is_none());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue