-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![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")) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters