Skip to content

Commit

Permalink
Merge clap-rs#2859
Browse files Browse the repository at this point in the history
2859: Partial Revert of "Change MissingArgumentOrSubcommand to DisplayHelpO… r=pksunkara a=epage



Co-authored-by: Ed Page <[email protected]>
  • Loading branch information
bors[bot] and epage authored Oct 12, 2021
2 parents 93decf7 + f48261a commit 5f3fe49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/parse/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ impl Error {
pub fn use_stderr(&self) -> bool {
!matches!(
self.kind,
ErrorKind::DisplayHelp
| ErrorKind::DisplayVersion
| ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
ErrorKind::DisplayHelp | ErrorKind::DisplayVersion
)
}

Expand Down
7 changes: 5 additions & 2 deletions tests/app_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ fn arg_required_else_help() {
.setting(AppSettings::ArgRequiredElseHelp)
.arg(Arg::new("test").index(1))
.try_get_matches_from(vec![""]);

assert!(result.is_err());
let err = result.err().unwrap();
assert_eq!(
Expand All @@ -274,6 +275,7 @@ fn arg_required_else_help_over_reqs() {
.setting(AppSettings::ArgRequiredElseHelp)
.arg(Arg::new("test").index(1).required(true))
.try_get_matches_from(vec![""]);

assert!(result.is_err());
let err = result.err().unwrap();
assert_eq!(
Expand All @@ -297,7 +299,7 @@ fn arg_required_else_help_error_message() {
app,
"test",
ARG_REQUIRED_ELSE_HELP,
false
true // Unlike normal displaying of help, we should provide a fatal exit code
));
}

Expand All @@ -307,6 +309,7 @@ fn subcommand_required_else_help() {
.setting(AppSettings::SubcommandRequiredElseHelp)
.subcommand(App::new("info"))
.try_get_matches_from(&[""]);

assert!(result.is_err());
let err = result.err().unwrap();
assert_eq!(
Expand All @@ -325,7 +328,7 @@ fn subcommand_required_else_help_error_message() {
app,
"test",
SUBCOMMAND_REQUIRED_ELSE_HELP,
false
true // Unlike normal displaying of help, we should provide a fatal exit code
));
}

Expand Down

0 comments on commit 5f3fe49

Please sign in to comment.