2015-10-01 03:34:23 +00:00
|
|
|
extern crate clap;
|
|
|
|
|
|
|
|
use clap::{App, Arg};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hidden_args() {
|
|
|
|
let mut app = App::new("test")
|
|
|
|
.author("Kevin K.")
|
|
|
|
.about("tests stuff")
|
|
|
|
.version("1.3")
|
2016-01-21 06:48:30 +00:00
|
|
|
.args(&[Arg::from_usage("-f, --flag 'some flag'").hidden(true),
|
2015-10-01 03:34:23 +00:00
|
|
|
Arg::from_usage("-F, --flag2 'some other flag'"),
|
|
|
|
Arg::from_usage("--option [opt] 'some option'")]);
|
|
|
|
// We call a get_matches method to cause --help and --version to be built
|
|
|
|
let _ = app.get_matches_from_safe_borrow(vec![""]);
|
|
|
|
|
|
|
|
// Now we check the output of print_help()
|
|
|
|
let mut help = vec![];
|
|
|
|
app.write_help(&mut help).ok().expect("failed to print help");
|
|
|
|
assert_eq!(&*String::from_utf8_lossy(&*help), &*String::from("test 1.3\n\
|
|
|
|
Kevin K.
|
|
|
|
tests stuff
|
|
|
|
|
|
|
|
USAGE:
|
2016-03-14 01:32:44 +00:00
|
|
|
test [FLAGS] [OPTIONS]
|
2015-10-01 03:34:23 +00:00
|
|
|
|
|
|
|
FLAGS:
|
|
|
|
-F, --flag2 some other flag
|
|
|
|
-h, --help Prints help information
|
|
|
|
-V, --version Prints version information
|
|
|
|
|
|
|
|
OPTIONS:
|
2016-05-30 09:39:54 +00:00
|
|
|
--option <opt> some option"));
|
2015-10-01 03:34:23 +00:00
|
|
|
}
|