2017-10-24 14:45:33 +00:00
|
|
|
extern crate clap;
|
|
|
|
extern crate regex;
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
include!("../clap-test.rs");
|
2018-01-09 15:24:24 +00:00
|
|
|
use clap::{App, Arg, SubCommand};
|
2017-10-24 14:45:33 +00:00
|
|
|
|
|
|
|
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(SubCommand::with_name("outer").subcommand(SubCommand::with_name("inner")))
|
2017-10-24 14:45:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn issue_1076() {
|
|
|
|
let mut app = get_app();
|
|
|
|
app.get_matches_from_safe_borrow(vec!["myprog"]);
|
|
|
|
app.get_matches_from_safe_borrow(vec!["myprog"]);
|
|
|
|
app.get_matches_from_safe_borrow(vec!["myprog"]);
|
|
|
|
}
|
|
|
|
}
|