From 8103e9760a9e6267490b5c09439416ef575d5991 Mon Sep 17 00:00:00 2001 From: Sebastian Toh Date: Wed, 28 Jun 2023 08:56:05 +0800 Subject: [PATCH] fix(ignore_errors): Allow help and version command --- clap_builder/src/builder/command.rs | 2 +- tests/builder/ignore_errors.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/clap_builder/src/builder/command.rs b/clap_builder/src/builder/command.rs index 5756e7dfd84..71ea73c0e3b 100644 --- a/clap_builder/src/builder/command.rs +++ b/clap_builder/src/builder/command.rs @@ -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); diff --git a/tests/builder/ignore_errors.rs b/tests/builder/ignore_errors.rs index a01f00aea8c..014149948df 100644 --- a/tests/builder/ignore_errors.rs +++ b/tests/builder/ignore_errors.rs @@ -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 @@ -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");