mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
tests: adds tests to last(true) args are printed in the usage even when required
This commit is contained in:
parent
8713da2372
commit
3223f21a90
1 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
|
|
||||||
|
@ -400,6 +401,19 @@ ARGS:
|
||||||
<BINFILE> The path of the binary to be profiled. If empty, Cargo.toml is searched for a binary.
|
<BINFILE> The path of the binary to be profiled. If empty, Cargo.toml is searched for a binary.
|
||||||
<ARGS>... Any arguments you wish to pass to the binary being profiled.";
|
<ARGS>... Any arguments you wish to pass to the binary being profiled.";
|
||||||
|
|
||||||
|
static LAST_ARG_REQ_MULT: &'static str = "example 1.0
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
example <FIRST>... [--] <SECOND>...
|
||||||
|
|
||||||
|
FLAGS:
|
||||||
|
-h, --help Prints help information
|
||||||
|
-V, --version Prints version information
|
||||||
|
|
||||||
|
ARGS:
|
||||||
|
<FIRST>... First
|
||||||
|
<SECOND>... Second";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn help_short() {
|
fn help_short() {
|
||||||
let m = App::new("test")
|
let m = App::new("test")
|
||||||
|
@ -450,6 +464,16 @@ fn help_subcommand() {
|
||||||
assert!(m.is_err());
|
assert!(m.is_err());
|
||||||
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn req_last_arg_usage() {
|
||||||
|
let app = clap_app!(example =>
|
||||||
|
(version: "1.0")
|
||||||
|
(@arg FIRST: ... * "First")
|
||||||
|
(@arg SECOND: ... * +last "Second")
|
||||||
|
);
|
||||||
|
assert!(test::compare_output(app, "example --help", LAST_ARG_REQ_MULT, false));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn args_with_last_usage() {
|
fn args_with_last_usage() {
|
||||||
|
|
Loading…
Reference in a new issue