Skip to content

Commit

Permalink
fix(ignore_errors): Allow help and version command
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiantoh committed Jun 28, 2023
1 parent d451e0a commit 8103e97
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion clap_builder/src/builder/command.rs
Expand Up @@ -3810,7 +3810,7 @@ impl Command {
// do the real parsing
let mut parser = Parser::new(self);
if let Err(error) = parser.get_matches_with(&mut matcher, raw_args, args_cursor) {
if self.is_set(AppSettings::IgnoreErrors) {
if self.is_set(AppSettings::IgnoreErrors) && error.use_stderr() {
debug!("Command::_do_parse: ignoring error: {error}");
} else {
return Err(error);
Expand Down
2 changes: 0 additions & 2 deletions tests/builder/ignore_errors.rs
Expand Up @@ -128,7 +128,6 @@ fn subcommand() {
}

#[test]
#[should_panic(expected = "`Result::unwrap_err()` on an `Ok` value")]
fn help_command() {
static HELP: &str = "\
Usage: test
Expand All @@ -143,7 +142,6 @@ Options:
}

#[test]
#[should_panic(expected = "`Result::unwrap_err()` on an `Ok` value")]
fn version_command() {
let cmd = Command::new("test").ignore_errors(true).version("0.1");

Expand Down

0 comments on commit 8103e97

Please sign in to comment.