Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass negative float as CLI argument #12691

Open
wdv4758h opened this issue Apr 28, 2024 · 1 comment · May be fixed by #12879
Open

Can't pass negative float as CLI argument #12691

wdv4758h opened this issue Apr 28, 2024 · 1 comment · May be fixed by #12879
Labels
🐛 bug Something isn't working inconsistent-behavior Behavior between different commands or types inconsistent/unexpected needs-design this feature requires design scripting Related to writing scripts

Comments

@wdv4758h
Copy link

Describe the bug

See more info in discussion link.

Discussed in #12473

Originally posted by wdv4758h April 11, 2024
This works:

# tmp.nu
def main [value: int] {
  print $value
}
nu tmp.nu -1

This does not work:

# tmp.nu
def main [value: float] {
  print $value
}
nu tmp.nu -1.0
Error: nu::parser::unknown_flag

  × The `main` command doesn't have flag `-1`.
   ╭─[<commandline>:1:7]
 1 │ main -1.0
   ·       ┬
   ·       ╰── unknown flag
   ╰────
  help: Available flags: --help(-h). Use `--help` for more information.

Having a .nu script file, and call that script with arguments. Not the case defining function in current nushell and call it.
For some reasons, int argument is ok, but float argument is not.

How to reproduce

Write a nu script file with float as argument. Call it from CLI with negative float arguments.

Expected behavior

Have a good way to pass negative float from CLI, like int.

Screenshots

No response

Configuration

key value
version 0.92.3
major 0
minor 92
patch 3
branch nightly
commit_hash 24ecb84
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-unknown-linux-gnu
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-04-28 01:44:34 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, sqlite, static-link-openssl, system-clipboard, trash, which
installed_plugins query

Additional context

No response

@wdv4758h wdv4758h added the needs-triage An issue that hasn't had any proper look label Apr 28, 2024
@sholderbach sholderbach added 🐛 bug Something isn't working needs-design this feature requires design scripting Related to writing scripts inconsistent-behavior Behavior between different commands or types inconsistent/unexpected and removed needs-triage An issue that hasn't had any proper look labels May 3, 2024
@b-van-b
Copy link

b-van-b commented May 5, 2024

I've noticed that you can still pass a negative value if you put it in parentheses, but only if the command has been added to nu with def or use:

# tmp.nu
export def main [value: float] {
  print $value
}
> nu tmp.nu (-1.5)
Error: nu::parser::unknown_flag

  × The `main` command doesn't have flag `-1`.
   ╭─[<commandline>:1:7]
 1 │ main -1.5
   ·       ┬
   ·       ╰── unknown flag
   ╰────
  help: Available flags: --help(-h). Use `--help` for more information.
  > use tmp.nu
  > tmp (-1.5)
  -1.5

@WindSoilder WindSoilder linked a pull request May 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working inconsistent-behavior Behavior between different commands or types inconsistent/unexpected needs-design this feature requires design scripting Related to writing scripts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants