mirror of
https://github.com/nushell/nushell.git
synced 2025-04-03 06:01:11 +02:00
Fix short flags with extra (#696)
This commit is contained in:
parent
3478f35330
commit
f016a5cb72
@ -2350,21 +2350,12 @@ pub fn parse_signature_helper(
|
|||||||
error = error.or_else(|| {
|
error = error.or_else(|| {
|
||||||
Some(ParseError::Expected("short flag".into(), span))
|
Some(ParseError::Expected("short flag".into(), span))
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
args.push(Arg::Flag(Flag {
|
|
||||||
arg: None,
|
|
||||||
desc: String::new(),
|
|
||||||
long: String::new(),
|
|
||||||
short: None,
|
|
||||||
required: false,
|
|
||||||
var_id: None,
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
let mut encoded_var_name = vec![0u8; 4];
|
let mut encoded_var_name = vec![0u8; 4];
|
||||||
let len = chars[0].encode_utf8(&mut encoded_var_name).len();
|
let len = chars[0].encode_utf8(&mut encoded_var_name).len();
|
||||||
let variable_name = encoded_var_name[0..len].to_vec();
|
let variable_name = encoded_var_name[0..len].to_vec();
|
||||||
let var_id =
|
let var_id = working_set.add_variable(variable_name, Type::Unknown);
|
||||||
working_set.add_variable(variable_name, Type::Unknown);
|
|
||||||
|
|
||||||
args.push(Arg::Flag(Flag {
|
args.push(Arg::Flag(Flag {
|
||||||
arg: None,
|
arg: None,
|
||||||
@ -2374,7 +2365,6 @@ pub fn parse_signature_helper(
|
|||||||
required: false,
|
required: false,
|
||||||
var_id: Some(var_id),
|
var_id: Some(var_id),
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
} else if contents.starts_with(b"(-") {
|
} else if contents.starts_with(b"(-") {
|
||||||
let short_flag = &contents[2..];
|
let short_flag = &contents[2..];
|
||||||
|
|
||||||
|
@ -134,3 +134,8 @@ fn multiline_pipe_in_block() -> TestResult {
|
|||||||
"5",
|
"5",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bad_short_flag() -> TestResult {
|
||||||
|
fail_test(r#"def foo3 [-l?:int] { $l }"#, "short flag")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user