fix(ignore_errors): Allow help and version command

This commit is contained in:
Sebastian Toh 2023-06-28 08:56:05 +08:00
parent d451e0a60c
commit 8103e9760a
2 changed files with 1 additions and 3 deletions

View file

@ -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);

View file

@ -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");