mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
Fix short flags with extra (#696)
This commit is contained in:
parent
3478f35330
commit
f016a5cb72
@ -2350,31 +2350,21 @@ pub fn parse_signature_helper(
|
||||
error = error.or_else(|| {
|
||||
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 len = chars[0].encode_utf8(&mut encoded_var_name).len();
|
||||
let variable_name = encoded_var_name[0..len].to_vec();
|
||||
let var_id =
|
||||
working_set.add_variable(variable_name, Type::Unknown);
|
||||
|
||||
args.push(Arg::Flag(Flag {
|
||||
arg: None,
|
||||
desc: String::new(),
|
||||
long: String::new(),
|
||||
short: Some(chars[0]),
|
||||
required: false,
|
||||
var_id: Some(var_id),
|
||||
}));
|
||||
}
|
||||
|
||||
let mut encoded_var_name = vec![0u8; 4];
|
||||
let len = chars[0].encode_utf8(&mut encoded_var_name).len();
|
||||
let variable_name = encoded_var_name[0..len].to_vec();
|
||||
let var_id = working_set.add_variable(variable_name, Type::Unknown);
|
||||
|
||||
args.push(Arg::Flag(Flag {
|
||||
arg: None,
|
||||
desc: String::new(),
|
||||
long: String::new(),
|
||||
short: Some(chars[0]),
|
||||
required: false,
|
||||
var_id: Some(var_id),
|
||||
}));
|
||||
} else if contents.starts_with(b"(-") {
|
||||
let short_flag = &contents[2..];
|
||||
|
||||
|
@ -134,3 +134,8 @@ fn multiline_pipe_in_block() -> TestResult {
|
||||
"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