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,38 +1439,33 @@ 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(),
); );
let value = lite_cmd.parts[idx].item[offset..]
.to_string()
.spanned(flag_value);
let (arg, err) = parse_arg(*shape, scope, &value);
named.insert_mandatory(
full_name.clone(),
lite_cmd.parts[idx].span,
arg,
);
if let Some(value_span) = flag_value { if error.is_none() {
let value = lite_cmd.parts[idx].item[offset..] error = err;
.to_string()
.spanned(value_span);
let (arg, err) = parse_arg(*shape, scope, &value);
named.insert_mandatory(
full_name.clone(),
lite_cmd.parts[idx].span,
arg,
);
if error.is_none() {
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