Ensure correct partial key=value flag. (#3518)

This commit is contained in:
Andrés N. Robalino 2021-05-29 23:19:58 -05:00 committed by GitHub
parent 4b11b283ac
commit a5c14ba7d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1439,29 +1439,25 @@ fn parse_internal_command(
if lite_cmd.parts[idx].item.contains('=') {
let mut offset = 0;
lite_cmd.parts[idx]
let value = lite_cmd.parts[idx]
.item
.chars()
.skip_while(|prop| {
offset += 1;
*prop != '='
})
.skip(1)
.for_each(drop);
.nth(1);
let flag_value = Span::new_option(
lite_cmd.parts[idx].span.start()
+ (lite_cmd.parts[idx].span.start() - offset),
offset = if value.is_none() { offset - 1 } else { offset };
let flag_value = Span::new(
lite_cmd.parts[idx].span.start() + offset,
lite_cmd.parts[idx].span.end(),
);
if let Some(value_span) = flag_value {
let value = lite_cmd.parts[idx].item[offset..]
.to_string()
.spanned(value_span);
.spanned(flag_value);
let (arg, err) = parse_arg(*shape, scope, &value);
named.insert_mandatory(
full_name.clone(),
lite_cmd.parts[idx].span,
@ -1471,7 +1467,6 @@ fn parse_internal_command(
if error.is_none() {
error = err;
}
}
} else if idx == lite_cmd.parts.len() {
// Oops, we're missing the argument to our named argument
if error.is_none() {