clap/tests/global_args.rs

37 lines
1.1 KiB
Rust
Raw Normal View History

extern crate clap;
extern crate regex;
#[cfg(test)]
mod tests {
include!("../clap-test.rs");
2018-11-14 17:05:06 +00:00
use clap::{App, Arg};
fn get_app() -> App<'static, 'static> {
App::new("myprog")
2018-01-25 04:05:05 +00:00
.arg(
Arg::with_name("GLOBAL_ARG")
.long("global-arg")
.help("Specifies something needed by the subcommands")
.global(true)
.takes_value(true)
.default_value("default_value"),
)
.arg(
Arg::with_name("GLOBAL_FLAG")
.long("global-flag")
.help("Specifies something needed by the subcommands")
.multiple(true)
.global(true),
)
.subcommand(App::new("outer").subcommand(App::new("inner")))
}
#[test]
fn issue_1076() {
let mut app = get_app();
let _ = app.try_get_matches_from_mut(vec!["myprog"]);
let _ = app.try_get_matches_from_mut(vec!["myprog"]);
let _ = app.try_get_matches_from_mut(vec!["myprog"]);
}
}