Skip to content

Commit

Permalink
fix(parser): Don't panic on --=
Browse files Browse the repository at this point in the history
This broke when we introduced clap_lex and then did a refactor on top.
We put in guards to say that escapes shouldn't happen but missed `--=`
which isn't quite an escape.

Not fully set on what error should be returned in this case (we are
returning roughly what we used to) but at least
we aren't panicing.

Fixes #3858
  • Loading branch information
epage committed Jun 21, 2022
1 parent dabb571 commit 01da890
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,8 +738,10 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
}
};
if long_arg.is_empty() {
debug_assert!(long_value.is_none(), "{:?}", long_value);
return Ok(ParseResult::NoArg);
debug_assert!(
long_value.is_some(),
"`--` should be filtered out before this point"
);
}

let arg = if let Some(arg) = self.cmd.get_keymap().get(long_arg) {
Expand Down

0 comments on commit 01da890

Please sign in to comment.