mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
run ensure_flag_arg_type for short flag values (#14074)
Closes #13654 # User-Facing Changes - Short flags are now fully type-checked, including null and record signatures for literal arguments: ```nushell def test [-v: record<l: int>] {}; test -v null # error test -v {l: ""} # error def test2 [-v: int] {}; let v = "" test2 -v $v # error ``` - `polars unpivot` `--index`/`--on` and `into value --columns` now accept `list` values
This commit is contained in:
@ -1067,30 +1067,27 @@ pub fn parse_internal_call(
|
||||
if let Some(arg_shape) = flag.arg {
|
||||
if let Some(arg) = spans.get(spans_idx + 1) {
|
||||
let arg = parse_value(working_set, *arg, &arg_shape);
|
||||
let (arg_name, val_expression) = ensure_flag_arg_type(
|
||||
working_set,
|
||||
flag.long.clone(),
|
||||
arg.clone(),
|
||||
&arg_shape,
|
||||
spans[spans_idx],
|
||||
);
|
||||
|
||||
if flag.long.is_empty() {
|
||||
if let Some(short) = flag.short {
|
||||
call.add_named((
|
||||
Spanned {
|
||||
item: String::new(),
|
||||
span: spans[spans_idx],
|
||||
},
|
||||
arg_name,
|
||||
Some(Spanned {
|
||||
item: short.to_string(),
|
||||
span: spans[spans_idx],
|
||||
}),
|
||||
Some(arg),
|
||||
Some(val_expression),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
call.add_named((
|
||||
Spanned {
|
||||
item: flag.long.clone(),
|
||||
span: spans[spans_idx],
|
||||
},
|
||||
None,
|
||||
Some(arg),
|
||||
));
|
||||
call.add_named((arg_name, None, Some(val_expression)));
|
||||
}
|
||||
spans_idx += 1;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user