2020-02-04 08:10:53 +00:00
|
|
|
mod utils;
|
2017-10-24 14:45:33 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
use clap::{App, Arg};
|
2017-10-24 14:45:33 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
fn get_app() -> App<'static> {
|
|
|
|
App::new("myprog")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("GLOBAL_ARG")
|
|
|
|
.long("global-arg")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Specifies something needed by the subcommands")
|
2020-02-04 08:10:53 +00:00
|
|
|
.global(true)
|
|
|
|
.takes_value(true)
|
|
|
|
.default_value("default_value"),
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("GLOBAL_FLAG")
|
|
|
|
.long("global-flag")
|
2020-04-21 15:51:38 +00:00
|
|
|
.about("Specifies something needed by the subcommands")
|
2020-02-04 08:10:53 +00:00
|
|
|
.multiple(true)
|
|
|
|
.global(true),
|
|
|
|
)
|
|
|
|
.subcommand(App::new("outer").subcommand(App::new("inner")))
|
|
|
|
}
|
2017-10-24 14:45:33 +00:00
|
|
|
|
2020-02-04 08:10:53 +00:00
|
|
|
#[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"]);
|
2017-10-24 14:45:33 +00:00
|
|
|
}
|