mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 06:12:40 +00:00
65b9c88b3c
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.
27 lines
634 B
Rust
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"))
|
|
);
|
|
}
|