clap/tests/builder/command.rs
Ed Page 65b9c88b3c fix: Update app_from_crate for App rename
Instead of just renaming it, I reconsidered what the API should look
like.  A custom separator for author does not make sense positionally
but accepting a name, and defaulting it, does fit with what someone
would expect.

I removed the `_from_crate` suffix because it doesn't seem necessary.
We don't have this kind of naming for the derive.  I feel it cleans
things up this way.
2022-02-15 08:39:07 -06:00

27 lines
634 B
Rust

#![cfg(feature = "cargo")]
use clap::{command, error::ErrorKind};
static EVERYTHING: &str = "clap {{version}}
A simple to use, efficient, and full-featured Command Line Argument Parser
USAGE:
clap
OPTIONS:
-h, --help Print help information
-V, --version Print version information
";
#[test]
fn command() {
let res = command!().try_get_matches_from(vec!["clap", "--help"]);
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"))
);
}