mirror of
https://github.com/nushell/nushell.git
synced 2025-02-17 19:11:26 +01:00
allow passing float value to custom command (#12879)
# Description Fixes: #12691 In `parse_short_flag`, it only checks special cases for `SyntaxShape::Int`, `SyntaxShape::Number` to allow a flag to be a number. This pr adds `SyntaxShape::Float` to allow a flag to be float number. # User-Facing Changes This is possible after this pr: ```nushell def spam [val: float] { $val }; spam -1.4 ``` # Tests + Formatting Added 1 test
This commit is contained in:
parent
e20113a0eb
commit
1b8eb23785
@ -486,7 +486,7 @@ fn parse_short_flags(
|
|||||||
&& matches!(
|
&& matches!(
|
||||||
sig.get_positional(positional_idx),
|
sig.get_positional(positional_idx),
|
||||||
Some(PositionalArg {
|
Some(PositionalArg {
|
||||||
shape: SyntaxShape::Int | SyntaxShape::Number,
|
shape: SyntaxShape::Int | SyntaxShape::Number | SyntaxShape::Float,
|
||||||
..
|
..
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -274,3 +274,9 @@ fn dont_allow_implicit_casting_between_glob_and_string() -> TestResult {
|
|||||||
"can't convert",
|
"can't convert",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn allow_pass_negative_float() -> TestResult {
|
||||||
|
run_test("def spam [val: float] { $val }; spam -1.4", "-1.4")?;
|
||||||
|
run_test("def spam [val: float] { $val }; spam -2", "-2")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user