d2c87ad4b4
# Description Fixes: #10450 This pr differentiating between `--x: bool` and `--x` Here are examples which demostrate difference between them: ```nushell def a [--x: bool] { $x }; a --x # not allowed, you need to parse a value to the flag. a # it's allowed, and the value of `$x` is false, which behaves the same to `def a [--x] { $x }; a` ``` For boolean flag with default value, it works a little bit different to #10450 mentioned: ```nushell def foo [--option: bool = false] { $option } foo # output false foo --option # not allowed, you need to parse a value to the flag. foo --option true # output true ``` # User-Facing Changes After the pr, the following code is not allowed: ```nushell def a [--x: bool] { $x }; a --x ``` Instead, you have to pass a value to flag `--x` like `a --x false`. But bare flag works in the same way as before. ## Update: one more breaking change to help on #7260 ``` def foo [--option: bool] { $option == null } foo ``` After the pr, if we don't use a boolean flag, the value will be `null` instead of `true`. Because here `--option: bool` is treated as a flag rather than a switch --------- Co-authored-by: amtoine <stevan.antoine@gmail.com> |
||
---|---|---|
.. | ||
src | ||
std | ||
tests | ||
Cargo.toml | ||
CONTRIBUTING.md | ||
LICENSE | ||
README.md |
Welcome to the standard library of `nushell`!
The standard library is a pure-nushell
collection of custom commands which
provide interactive utilities and building blocks for users writing casual scripts or complex applications.
To see what's here:
> use std
> help commands | select name usage | where name =~ "std "
╭────┬─────────────────────────────┬────────────────────────────────────────────────────────────────╮
│ # │ name │ usage │
├────┼─────────────────────────────┼────────────────────────────────────────────────────────────────┤
│ 0 │ std assert │ Universal assert command │
│ 1 │ std assert equal │ Assert $left == $right │
. . .
│ 11 │ std clip │ put the end of a pipe into the system clipboard. │
│ 12 │ std dirs add │ Add one or more directories to the list. │
. . .
├────┼─────────────────────────────┼────────────────────────────────────────────────────────────────┤
│ # │ name │ usage │
╰────┴─────────────────────────────┴────────────────────────────────────────────────────────────────╯
🧰 Using the standard library in the REPL or in scripts
All commands in the standard library must be "imported" into the running environment
(the interactive read-execute-print-loop (REPL) or a .nu
script) using the
use
command.
You can choose to import the whole module, but then must refer to individual commands with a std
prefix, e.g:
use std
std log debug "Running now"
std assert (1 == 2)
Or you can enumerate the specific commands you want to import and invoke them without the std
prefix.
use std ["log debug" assert]
log debug "Running again"
assert (2 == 1)
This is probably the form of import you'll want to add to your env.nu
for interactive use.
✏️ contribute to the standard library
You're invited to contribute to the standard library! See CONTRIBUTING.md for details