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