From c8e669c690db574d306d498a4057ddb25573196d Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Wed, 30 Dec 2020 00:39:20 +0800 Subject: [PATCH] Eliminate unreachable branch comment fix Apply fmt --- src/parse/parser.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/parse/parser.rs b/src/parse/parser.rs index f8e0b52f..4e05473f 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -892,7 +892,7 @@ impl<'help, 'app> Parser<'help, 'app> { { let mut p = Parser::new(sc); // HACK: maintain indexes between parsers - // FlagSubCommand short arg needs to revist the current short args, but skip the subcommand itself + // FlagSubCommand short arg needs to revisit the current short args, but skip the subcommand itself if keep_state { p.cur_idx.set(self.cur_idx.get()); p.skip_idxs = self.skip_idxs; @@ -1034,8 +1034,11 @@ impl<'help, 'app> Parser<'help, 'app> { .iter() .map(|x| x.to_str().expect(INVALID_UTF8)) .collect(); - self.did_you_mean_error(arg.to_str().expect(INVALID_UTF8), matcher, &remaining_args) - .map(|_| ParseResult::NotFound) + Err(self.did_you_mean_error( + arg.to_str().expect(INVALID_UTF8), + matcher, + &remaining_args, + )) } } @@ -1470,7 +1473,7 @@ impl<'help, 'app> Parser<'help, 'app> { arg: &str, matcher: &mut ArgMatcher, remaining_args: &[&str], - ) -> ClapResult<()> { + ) -> ClapError { debug!("Parser::did_you_mean_error: arg={}", arg); // Didn't match a flag or option let longs = self @@ -1511,12 +1514,12 @@ impl<'help, 'app> Parser<'help, 'app> { .cloned() .collect(); - Err(ClapError::unknown_argument( + ClapError::unknown_argument( format!("--{}", arg), did_you_mean, Usage::new(self).create_usage_with_title(&*used), self.app.color(), - )) + ) } pub(crate) fn write_help_err(&self) -> ClapResult {