2022-02-15 03:16:51 +00:00
|
|
|
#![cfg(feature = "cargo")]
|
|
|
|
|
|
|
|
use clap::{command, error::ErrorKind};
|
|
|
|
|
2022-08-31 14:29:00 +00:00
|
|
|
use crate::utils;
|
|
|
|
|
2022-02-15 03:16:51 +00:00
|
|
|
static EVERYTHING: &str = "clap {{version}}
|
|
|
|
A simple to use, efficient, and full-featured Command Line Argument Parser
|
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: clap
|
2022-02-15 03:16:51 +00:00
|
|
|
|
2022-08-26 14:40:23 +00:00
|
|
|
Options:
|
2023-01-03 16:49:43 +00:00
|
|
|
-h, --help Print help
|
|
|
|
-V, --version Print version
|
2022-02-15 03:16:51 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn command() {
|
2022-08-31 14:29:00 +00:00
|
|
|
let res = command!()
|
|
|
|
.help_template(utils::FULL_TEMPLATE)
|
|
|
|
.try_get_matches_from(vec!["clap", "--help"]);
|
2022-02-15 03:16:51 +00:00
|
|
|
|
|
|
|
assert!(res.is_err());
|
|
|
|
let err = res.unwrap_err();
|
|
|
|
assert_eq!(err.kind(), ErrorKind::DisplayHelp);
|
|
|
|
assert_eq!(
|
|
|
|
err.to_string(),
|
|
|
|
EVERYTHING.replace("{{version}}", env!("CARGO_PKG_VERSION"))
|
|
|
|
);
|
|
|
|
}
|