Skip to content

Commit 8103e97

Browse files
committed
fix(ignore_errors): Allow help and version command
1 parent d451e0a commit 8103e97

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

clap_builder/src/builder/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3810,7 +3810,7 @@ impl Command {
38103810
// do the real parsing
38113811
let mut parser = Parser::new(self);
38123812
if let Err(error) = parser.get_matches_with(&mut matcher, raw_args, args_cursor) {
3813-
if self.is_set(AppSettings::IgnoreErrors) {
3813+
if self.is_set(AppSettings::IgnoreErrors) && error.use_stderr() {
38143814
debug!("Command::_do_parse: ignoring error: {error}");
38153815
} else {
38163816
return Err(error);

tests/builder/ignore_errors.rs

-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ fn subcommand() {
128128
}
129129

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

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

0 commit comments

Comments
 (0)