Commit Graph

10549 Commits

Author SHA1 Message Date
uraneko
cd1094c94e Sort help message flags by required field (#16476)
closes #16462.

The --help flag will now appear after all required flags in help
messages.

## Release notes summary - What our users need to know
N/A

## Tasks after submitting
N/A
2025-08-21 11:46:29 +02:00
dependabot[bot]
e41ba7101f build(deps): bump tempfile from 3.20.0 to 3.21.0 (#16480) 2025-08-20 18:46:26 +00:00
zc he
3877bfb61a fix(parser): env shorthand false positive (#16337)
More restrictions on env shorthand parsing to avoid false positives.

Fixes #16332
2025-08-20 18:57:33 +03:00
zc he
343e5cf191 fix(parser): export def exposes arguments to current scope (#16262)
- Skip the extra call of `parse_internal_call` unless the `help` flag is set.
- Wrap `parse_internal_call` in a new scope to avoid leaking variables.

Closes #16211
2025-08-20 18:10:16 +03:00
rose
abeb787115 Make Span mandatory for some fields in ShellError (#16471)
Some variants of `ShellError` have `Option<Span>` that really don't need
to. This PR removes the `Option` for `ConfigDirNotFound`
and `DisabledOsSupport`.

Also removes `ShellError::InterruptedByUser`, which had exactly one
usage, in favor of the more widely used `ShellError::Interrupted`

Rel: #13005

## Release notes summary - What our users need to know
N/A
2025-08-20 09:56:06 -04:00
dependabot[bot]
4f1300bdf6 build(deps): bump crate-ci/typos from 1.35.4 to 1.35.5 (#16478) 2025-08-20 13:18:41 +08:00
Bruce Weirdan
258a7f6e97 Make xml: prefix always available in query xml (#16472)
## Release notes summary - What our users need to know

`query xml` now has `xml:` namespace prefix available by default,
without the need to specify it via `--namespaces`.

## Details and motivation

`xml:` prefix is rarely (if ever) explicitly declared in XML sources, so
its associated namespace is a bit obscure. `sxd_xpath` seems to assume
it's `http://www.w3.org/XML/1998/namespace`, so we register it by
default.

## Tasks after submitting
<!-- Remove any tasks which aren't relevant for your PR, or add your own
-->
- [ ] Update the
[documentation](https://github.com/nushell/nushell.github.io)
2025-08-19 16:39:30 -05:00
rose
dd664e3cdb Add assertion that DeprecationEntry flag do not have dashes (#16475)
Added a `debug_assert` when using `DeprecationType::Flag` to ensure that
the dashes aren't included as part of the flag name. This will hopefully
catch something like the issue discovered in #16473 from occurring.

## Release notes summary - What our users need to know
N/A

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2025-08-19 22:28:30 +02:00
rose
2715992d2f Mitigate watch -d breaking change (#16473)
This PR reverts the breaking change of short flag change of `watch -d`
to `--debounce` instead of `--debounce-ms`. This fully prevents #16187
from being a breaking change.

Before #16187:
```nushell
watch -d 1000 foo {}
# => Now watching files at "/home/rose/foo". Press ctrl+c to abort.
```

Before this PR (after #16187):
```nushell
watch -d 1000 foo {}
# => Error: nu::parser::parse_mismatch
# => 
# =>   × Parse mismatch during operation.
# =>    ╭─[entry #15:1:10]
# =>  1 │ watch -d 1000 foo {}
# =>    ·          ──┬─
# =>    ·            ╰── expected duration with valid units
# =>    ╰────
```

After this PR (after #16187):
```nushell
watch -d 1000 foo {}
# => Warning: nu::parser::deprecated
# => 
# =>   ⚠ Flag deprecated.
# =>    ╭─[entry #3:1:7]
# =>  1 │ watch -d 1000 foo {}
# =>    ·       ─┬
# =>    ·        ╰── watch --debounce-ms was deprecated in 0.107.0 and will be removed in 0.109.0.
# =>    ╰────
# =>   help: `--debounce-ms` will be removed in favour of  `--debounce`
# => 
# => Now watching files at "/home/rose/foo". Press ctrl+c to abort.
```

This PR also fixes the `DeprecationEntry` which incorrectly had a `--`
in it, which I failed to realize when reviewing #16187. We should add a
`debug_assert` or something for this.

Rel: #16187

## Release notes summary - What our users need to know

N/A

## Tasks after submitting

- [ ] Add `debug_assert` for `DeprecationType::Flag`s with `--`
2025-08-19 21:04:05 +02:00
andoalon
bc8acfd2ea Add --endian flag to into binary (#16466)
This flag brings `into binary` in line with other commands such as `into
int`.

The motivation to do this now comes from #16435:
the change to `format bits` to show the output in big endian makes the
output of `42 | format bits` and `42 | into binary | format bits`
diverge in little endian platforms. By adding this flag, we give the
user the option to make them equal: `42 | into binary --endian big |
format bits` (well, equal minus the padding zeros).

The default behavior is kept the same, since the default value is using
the platforms native endianness.

Results in a little endian platform (with the changes from both
PRs)



## Release notes summary - What our users need to know
Add `--endian` flag to `into binary` to select the endianness of how primitive types are layed out
```nushell
~> 258 | format bits
00000001 00000010
~> 258 | into binary --compact | format bits
00000010 00000001
~> 258 | into binary --compact --endian big | format bits
00000001 00000010
~> 258 | into binary | format bits
00000010 00000001 00000000 00000000 00000000 00000000 00000000 00000000
~> 258 | into binary --endian big | format bits
00000000 00000000 00000000 00000000 00000000 00000000 00000001 00000010
```

## Tasks after submitting
None
2025-08-19 16:42:30 +02:00
Stefan Holderbach
5a7d9062a1 chore: Clippy and dead code elimination pass (#16469)
- **Fix `clippy::non_canonical_partial_ord_impl`**
- **Clippy from stable `needless_return`**
- **Dead code found by `cargo +stable clippy`**
- **Remove dead function used by pre-uu `mv --update`**
- **clippy::manual_is_multiple_of**

## Release notes summary - What our users need to know
N/A
2025-08-19 16:39:48 +02:00
Stefan Holderbach
43a308f629 Update PLATFORM_SUPPORT to mention loongarch limitations (#16470)
#16455 had to restrict to `panic=abort` which breaks the error recovery
(and terminal raw mode disabling) on panic.

Mention this and the fact that loongarch64 are build by
https://github.com/nushell/nightly/releases
2025-08-19 22:07:48 +08:00
Justin Ma
c4236824d1 Fix loongarch64 builds for rust 1.87.0 (#16455)
Fix loongarch64 builds for rust 1.87.0, should close #16441 

Test release:
https://github.com/hustcer/nushell/actions/runs/17021639773/job/48251578593

## Release notes summary - What our users need to know

Nothing
2025-08-19 14:31:36 +02:00
Stefan Holderbach
9ed6c12458 Use direct Value.as_str() in string commands (#16468)
Affects:
- `split chars`
- `split column`
- `split words`

Instead of the loose coercion provided by `.coerce_string` this can be a
direct check for the string identity of the particular `Value` as the
commands are sensibly restricted to `string` input types

Found through inspecting #9573

## Release notes summary - What our users need to know
N/A
2025-08-19 13:21:28 +02:00
Jan9103
5ce9c38540 fix(nu-lsp): hover on external 0x08 handling (#16316)
# Description
issue report: discord `#editor-support` 2025-07-30 (discords `copy
message link` button is broken)

The LSP hover uses `man` under the hood.
Some `man` implementations use `0x08` to underline text, make text bold,
etc.
Nu previously just stripped the `0x08`, leaving the duplicate
characters, random underscores, etc.

With this PR it strips both `0x08` and its preceding character before
stripping the ANSI.

`groff` (`man`'s rendering engine) prints the underscore first
(`_\x08A`) when underscoring (probably in case something cant print
chars on top of another) and thus the char before has to be stripped.

different `man` implementations accept different arguments (example: the
one i use errors from `-P`) and i was unable to find a env-var or
argument to fix the problem (`-T ascii` does nothing on my pc).

I am fairly new to `Cow` stuff, so this is probably far from the most
performant implementation.
Feel free to give me pointers, fork this PR, or whatever.

## Potential bugs

I would be suprised, but some `man` implementation might render the char
first and the underscore second.

## Testing

Apparently not every `man` implementation is affected by the original
bug..

I use:
* voidlinux (gnu)
* groff: `1.23.0`
* man: `man-db-2.13.0_1`
* editor: `helix 25.01.1 (bcb6c20a)`

```
> man rev | to json
"REV(1)                           User Commands                          REV(1)\n\nN\bNA\bAM\bME\bE\n       rev - reverse lines characterwise\n\nS\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS\n       r\bre\bev\bv [option] [_\bf_\bi_\bl_\be...]\n\nD\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN\n       The r\bre\bev\bv utility copies the specified files to standard output,\n       reversing the order of characters in every line. If no files are\n       specified, standard input is read.\n\n       This utility is a line-oriented tool and it uses in-memory allocated\n       buffer for a whole wide-char line. If the input file is huge and\n       without line breaks then allocating the memory for the file may be\n       unsuccessful.\n\nO\bOP\bPT\bTI\bIO\bON\bNS\bS\n       -\b-h\bh, -\b--\b-h\bhe\bel\blp\bp\n           Display help text and exit.\n\n       -\b-V\bV, -\b--\b-v\bve\ber\brs\bsi\bio\bon\bn\n           Print version and exit.\n\n       -\b-0\b0, -\b--\b-z\bze\ber\bro\bo\n           _\bZ_\be_\br_\bo _\bt_\be_\br_\bm_\bi_\bn_\ba_\bt_\bi_\bo_\bn. Use the byte '\\0' as line separator.\n\nS\bSE\bEE\bE A\bAL\bLS\bSO\bO\n       t\bta\bac\bc(1)\n\nR\bRE\bEP\bPO\bOR\bRT\bTI\bIN\bNG\bG B\bBU\bUG\bGS\bS\n       For bug reports, use the issue tracker at\n       <https://github.com/util-linux/util-linux/issues>.\n\nA\bAV\bVA\bAI\bIL\bLA\bAB\bBI\bIL\bLI\bIT\bTY\bY\n       The r\bre\bev\bv command is part of the util-linux package which can be\n       downloaded from _\bL_\bi_\bn_\bu_\bx _\bK_\be_\br_\bn_\be_\bl _\bA_\br_\bc_\bh_\bi_\bv_\be\n       <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\nutil-linux 2.40.2                 2024-01-31                            REV(1)"
```

# User-Facing Changes

I think this is just a bugfix.

# Tests + Formatting

- [x] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used`
to check that you're using the standard code style
- [x] `cargo test --workspace` to check that all tests pass (on Windows
make sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- [x] `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

# After Submitting

Co-authored-by: blindFS <blindfs19@gmail.com>
2025-08-19 17:15:14 +08:00
Harper Andrews
458b8a5362 Fix error message: custom commands cannot be const (#16393)
# Description

Fixes the error you get when you parse something like `const c = random
int` to no longer imply that custom commands can be `const`. My
understanding is that they currently cannot (though that feature is
being tracked at #15074).

# User-Facing Changes

* Improved error message

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2025-08-19 11:02:26 +02:00
Bruce Weirdan
778601b821 Extend nodeset output formats for query xml (#16465)
Refs
https://discord.com/channels/601130461678272522/615329862395101194/1406413134402551869

## Release notes summary - What our users need to know

`query xml` now can output additional information when it returns
Nodesets:

* `--output-type` enables `type` column. It includes the node type
found, e.g. `element` or `comment`
* `--output-names` adds `local_name`, `prefixed_name` and `namespace`
columns
  * `--output-string-value` (re)adds `string_value` column

If you're using any of the `--output-*` switches, and want
`string_value` column to show up, pass `--output-string-value`
explicitly. In the absence of any `--output-*` attributes,
`--output-string-value` is assumed to be on.

## Tasks after submitting
<!-- Remove any tasks which aren't relevant for your PR, or add your own
-->
- [ ] Update the
[documentation](https://github.com/nushell/nushell.github.io)
2025-08-18 18:57:56 -05:00
dependabot[bot]
7107fc9bc3 build(deps): bump actions/checkout from 4 to 5 (#16426) 2025-08-18 20:48:54 +00:00
dependabot[bot]
1248370437 build(deps): bump oem_cp from 2.0.0 to 2.1.0 (#16298) 2025-08-18 20:48:36 +00:00
rose
3fccd51e54 Tweak PR template (#16460)
<!--
Thank you for improving Nushell!
Please, read our contributing guide:
https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md
-->

Based on core team feedback, this tweaks the PR template again. Instead
of having an explicit "Motivation and technical details", we can leave
the PR template more free-form. Leaving the template more free form lets
people write the PR how they want; for example, @sholderbach likes to
let `gh pr open` fill in the description from the commit messages,
whereas @NotTheDr01ds likes to fill in the "Release notes summary
section" first, then provide more details below.

I tried to make the comment for the release notes summary section more
clear while not blowing up the amount of comment lines in the PR
template. I've also added more information about the release notes
summary section to CONTRIBUTING.md, including re-emphasizing the fact
that this can be left blank until the PR is finalized and information
about how to structure the section.

I'm open to suggestions on the phrasing of the comments, this should be
as clear as possible ideally!

## Release notes summary - What our users need to know
N/A

---------

Co-authored-by: Douglas <32344964+NotTheDr01ds@users.noreply.github.com>
Co-authored-by: Ecorous <ecorous@outlook.com>
2025-08-18 22:43:52 +02:00
Bahex
bed0c99909 feat: watch returns a stream of events as a table when called without a closure (#16428)
`watch` command can now be used to _return a stream_ of detected events
instead of calling a closure with it's information, though using a
closure is still possible and existing uses won't break.

In addition to this:
```nushell
watch . {|operation, path, new_path|
    if $operation == "Write" and $path like "*.md" {
        md-lint $path
    }
}
```

Now this is also possible:
```nushell
watch .
| where operation == Write and path like "*.md"
| each { md-lint $in.path }
```
2025-08-18 23:28:15 +03:00
Bruce Weirdan
aea3309502 Use fixed column name for query xml output (#16461)
This is a breaking change.

Refs
https://discord.com/channels/601130461678272522/615329862395101194/1406413134402551869
Depends on (and includes) nushell/nushell#16459, which should be merged
first

Partially addresses nushell/nushell#15717

## Motivation and technical details

Variable column names are hard to work with. What's worse, currently
Nushell truncates the column name, making it even more unpredictable.
The only reliable way to deal with that is to rename the results column
like this:

```nushell
.... | query xml "//item/title|//title" | rename string_value | ...
```

so why would we make our users jump through these hoops? To provide some
parallels, `query db` does not add the query into its output, and
neither does `get`.

The choice of the column name comes from XPath spec:
https://www.w3.org/TR/xpath-10/#dt-string-value, adapted to Nushell
conventions

## Release notes summary - What our users need to know

`query xml` outputs the results (for nodeset results) in a column with a
fixed name.

Before:

```nushell 
open -r tests/fixtures/formats/jt.xml 
| query xml '//channel/title|//item/title'
# => ╭───┬───────────────────────────────────────────╮
# => │ # │           //channel/title|/...            │
# => ├───┼───────────────────────────────────────────┤
# => │ 0 │ JT                                        │
# => │ 1 │ Creating crossplatform Rust terminal apps │
# => ╰───┴───────────────────────────────────────────╯
```

Now:

```nushell 
open -r tests/fixtures/formats/jt.xml 
| query xml '//channel/title|//item/title'
# => ╭───┬───────────────────────────────────────────╮
# => │ # │             string_value                  │
# => ├───┼───────────────────────────────────────────┤
# => │ 0 │ JT                                        │
# => │ 1 │ Creating crossplatform Rust terminal apps │
# => ╰───┴───────────────────────────────────────────╯
```

## Tasks after submitting
<!-- Remove any tasks which aren't relevant for your PR, or add your own
-->
- [ ] Update the
[documentation](https://github.com/nushell/nushell.github.io)
2025-08-18 13:42:43 -05:00
Douglas
040a4eeaab Ability to specify a table name for kv commands (#16450)
Closes #15786 

## Release notes summary - What our users need to know

`std-rfc/kv` commands now take an optional `--table (-t)` argument which
allows a custom table name to be used. If not specified, the current
`std-kv-store` table will be used.

## Tasks after submitting

- [x] Added in-help example to `kv set`. Did not add examples to the
other `kv` commands since they should be obvious based on the initial
`kv set`.

## Additional details

Example:

```nushell
use std-rfc/kv *
kv set -t foo bar 5
kv list
# Empty list, since the value was placed in a custom table
# => ╭────────────╮
# => │ empty list │
# => ╰────────────╯
kv list -t foo
# => ╭───┬─────┬───────╮
# => │ # │ key │ value │
# => ├───┼─────┼───────┤
# => │ 0 │ bar │     5 │
# => ╰───┴─────┴───────╯
```

To protect against injection attacks, table names can only include
alphanumeric characters with `_` and `-`.
2025-08-18 08:19:05 -04:00
Bruce Weirdan
1ddae02da7 Multiple output types for query xml (#16459)
This is a breaking change.

Refs
https://discord.com/channels/601130461678272522/615329862395101194/1406413134402551869

## Release notes summary - What our users need to know

Previously, `query xml` always returned a table, even for scalar
results. Now scalar results will be returned as scalars.

For example

```nushell
open -r tests/fixtures/formats/jt.xml
| query xml 'false()'
```

used to return

```
╭───┬─────────╮
│ # │ false() │
├───┼─────────┤
│ 0 │ false   │
╰───┴─────────╯
```

and now it will return just `false`.

## Tasks after submitting
<!-- Remove any tasks which aren't relevant for your PR, or add your own
-->
- [ ] Update the
[documentation](https://github.com/nushell/nushell.github.io)
2025-08-18 06:34:57 -05:00
132ikl
7d5adf0a42 Redirect "Questions" issue option to Discussions (#16443)
This PR removes the "Question" issue template, and adds a section to the
issue creation menu labeled "Question" which redirects to a new Q&A
discussion post.

I have this set up on my fork if you want to see what it looks like:
https://github.com/132ikl/nushell/issues/new/choose

## Release notes summary - What our users need to know
N/A

## Tasks after submitting
- [ ] Convert all issues currently tagged with the "question" label into
Discussions
2025-08-17 22:33:30 +02:00
Bruce Weirdan
a3b00060b4 Quote strings containing = (#16440)
Fixes nushell/nushell#16438

## Release notes summary - What our users need to know

Previously, a record key `=` would not be quoted in `to nuon`, producing
invalid nuon output. It wasn't quoted in other string values either, but
it didn't cause problems there. Now any string containing `=` gets
quoted.
2025-08-17 22:33:07 +02:00
132ikl
625e7154e0 Add "Motivation and technical details (#16458)
## Motivation and technical details

This PR adds a "Motivation and technical details" section to the PR
template. It seems like not having an explicit section for this has
tripped some people up, so this PR adds an explicit heading for this to
go under.

## Release notes summary - What our users need to know

N/A
2025-08-17 22:29:21 +02:00
Stuart Carnie
fd4a04211a feat: commandline edit --accept to instantly execute command (#16193)
# Description

Fixes 
- #11065

Revised 
- #15092

Depends on

- https://github.com/nushell/reedline/pull/933

Adds the `--accept` flag to the `commandline` command, to immediately
accept the input.

Example use case: atuin

# User-facing changes

Users get the ability to pass `--accept` or `-A` to `commandline edit`
in order to immediately execute the resulting commandline.

# Tests + Formatting

I added two test cases that execute `commandline edit -A`.
There is also some documentation about their unintuitive expectations
output.

# After Submitting

The [docs](https://www.nushell.sh/commands/docs/commandline_edit.html)
can be updated to the new flag:

--accept, -A: immediately execute the command (no additional return
required)

> [!NOTE]
>
> This PR will be revised if / when
https://github.com/nushell/reedline/pull/933 is accepted

# Demo


[![asciicast](https://asciinema.org/a/Ql4r1oWu8J0C4MecmIZjxw5Pg.svg)](https://asciinema.org/a/Ql4r1oWu8J0C4MecmIZjxw5Pg)
2025-08-17 22:24:17 +02:00
Wind
a40f6d5cba fix uninlined_format_args clippy warnings (#16452)
I noticed some clippy errors while running clippy under 1.88.
```
error: variables can be used directly in the `format!` string
   --> src/config_files.rs:204:25
    |
204 |                         warn!("AutoLoading: {:?}", path);
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
    = note: `-D clippy::uninlined-format-args` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::uninlined_format_args)]`
```
And this pr is going to fix this.

## Release notes summary - What our users need to know
NaN

## Tasks after submitting
NaN
2025-08-17 12:41:36 +02:00
Piepmatz
0b8531ed9d Add well-optimized string types (#16446) 2025-08-16 18:01:38 +02:00
Darren Schroeder
36427a7434 update to rust version 1.87.0 (#16437)
The PR upgrades nushell to rust version 1.87.0.

## Dev overview from clippy
- I added `result_large_err` to clippy in the root Cargo.toml to avoid
the warnings (and a few places in plugins). At some point a more proper
fix, perhaps boxing these, will need to be performed. This PR is to just
get us over the hump.
- I boxed a couple areas in some commands
- I changed `rdr.bytes()` to `BufReader::new(rdr).bytes()` in nu-json

## Release notes summary - What our users need to know
Users can use rust version 1.87.0 to compile nushell now

## Tasks after submitting
N/A
2025-08-14 11:27:34 -05:00
Bahex
daf52ba5c8 refactor: run env_change hooks before pre_prompt hooks (#16356)
Change the order of hook evaluations, run `env_change` before `pre_prompt`.
New order of execution is: `env_change` -> `pre_prompt` -> `PROMPT_COMMAND`
2025-08-14 02:11:05 +03:00
Tyarel8
2f7f00001d feat(std/bench) add osc 9;4 progress bar (#16245)
# Description
Using `osc 9;4`, `bench` shows a progress bar or circle on supported
terminals, every 10 timing rounds to not degrade performance too much.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2025-08-13 16:49:39 -04:00
Bahex
ee7334a772 feat(get,select,reject): add --ignore-case which interprets cell-paths case insensitively, analogous to --optional (#16401)
# Description
Follow up to #16007

Also added some examples for existing flags which were previously
missing.

After the deprecation period of `--ignore-errors (-i)`, `-i` will be
used as the short form of this flag.

# User-Facing Changes
`get`, `select`, `reject` commands now have a `--ignore-case` flag,
which makes the commands interpret all cell-path arguments as completely
case insensitive.

# Tests + Formatting
+1

# After Submitting
Set a reminder for the `--ignore-errors` deprecation and using `-i` as
the short flag. Maybe we can make PRs in advance for future versions and
mark them with GitHub's milestones.
2025-08-13 16:45:33 -04:00
Tyarel8
3fe9c7c00c feat(each): noop on single null input, map-null equivalent (#16396)
# Description
Basically, now `null | each { "something" }` will be `null` instead of
`"something"`. Thanks to this, `each` can be used to map values similar
to `map-null` custom commands, for example:
- Before
```nu
let args = if $delay != null {
    ["--delay" ($delay | format duration sec | parse '{secs} {_}' | get 0.secs)]
} else {
    []
}
```
- After
```nu
let args = (
    $delay
    | each { ["--delay" ($in | format duration sec | parse '{secs} {_}' | get 0.secs)] }
    | default []
)
```

Please let me know if this change messes something up I'm not seeing.
# User-Facing Changes
- Before
```nu
→ null | each { "something" }
something
```
- After
```nu
→ null | each { "something" }
null
```
# Tests + Formatting
Added a test to check for this.

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-08-13 15:22:24 -05:00
132ikl
43992f5b6f Rework PR template (#16412) 2025-08-13 22:10:47 +02:00
Bruce Weirdan
91e72ae8b4 Validate std/random dice args (#16430)
Fixes #16429
2025-08-13 21:50:49 +02:00
Andrej Kolčin
da54ed8ea1 docs: document undocumented Signature methods (#16417)
Just a small PR which documents methods. I got confused what `rest` did
while working on a plugin, so I decided to document all of them.
2025-08-13 20:58:30 +02:00
dependabot[bot]
3eabc83c61 build(deps): bump crate-ci/typos from 1.35.1 to 1.35.4 (#16424) 2025-08-13 18:55:36 +00:00
dependabot[bot]
cc4a4a11f0 build(deps): bump sysinfo from 0.36.0 to 0.36.1 (#16423) 2025-08-13 18:55:11 +00:00
dependabot[bot]
d53e16748d build(deps): bump rayon from 1.10.0 to 1.11.0 (#16422) 2025-08-13 18:54:22 +00:00
Andrej Kolčin
4ead4ce4d6 feat: move random dice to std (#16420)
# Description

As per the suggestion in #16350, this PR moves `random dice` to std.
It's basically a thin wrapper over `random int` already.

# User-Facing Changes (deprecations)

## `random dice` moved to `std`

The `random dice` command has been rewritten in Nushell and moved to the
standard library. The `random dice` built-in is still available with a
deprecation error, but will be removed in 0.108. The new command can be
used as follows:

```nushell
use std/random

random dice
```

It's behavior, parameters, and defaults are the same.


# After Submitting

Update documentation to reflect the change.

Closes #16350
2025-08-13 20:45:45 +02:00
David Yamnitsky
31606a8fe1 Kill background jobs on interrupt (#16285)
# Description
This PR kills all background jobs on interrupt, as a fix for
https://github.com/nushell/nushell/issues/15947.

# User-Facing Changes
If you run the following: `job spawn { print "job spawned"; ^sleep
infinity }; ^sleep infinity`, then hit ctrl-c, the current behavior is
that the `sleep` process from the job will not be killed, it will
reparented to init. With this change, the process will be killed on
ctrl-c.

# Tests + Formatting
I was unsure of the best way to write a test for this.

# After Submitting

---------

Co-authored-by: 132ikl <132@ikl.sh>
2025-08-13 13:11:40 -04:00
Andrej Kolčin
7133a04e2f Improve wrong flag help (#16427)
# Description

Currently, when Nushell encounters an unknown flag, it prints all
options in the help string. This is pretty verbose and uses the
`formatted_flags` signature method, which isn't used anywhere else. This
commit refactors the parser to use `did_you_mean` instead, which only
suggest one closest option or sends the user to `help` if nothing close
is found.


# User-Facing Changes (Bug fixes and other changes)

## Improved error messages for misspelled flags

Previously, the help text for a missing flag would list all of them,
which could get verbose on a single line:

```nushell
~> ls --full-path
Error: nu::parser::unknown_flag

  × The `ls` command doesn't have flag `full-path`.
   ╭─[entry #8:1:4]
 1 │ ls --full-path
   ·    ─────┬─────
   ·         ╰── unknown flag
   ╰────
  help: Available flags: --help(-h), --all(-a), --long(-l), --short-names(-s), --full-paths(-f), --du(-d), --directory(-D), --mime-type(-m), --threads(-t). Use
        `--help` for more information.
```

The new error message only suggests the closest flag:

```nushell
> ls --full-path
Error: nu::parser::unknown_flag

  × The `ls` command doesn't have flag `full-path`.
   ╭─[entry #23:1:4]
 1 │ ls --full-path
   ·    ─────┬─────
   ·         ╰── unknown flag
   ╰────
  help: Did you mean: `--full-paths`?
```


---

Closes #16418
2025-08-13 06:25:18 -05:00
Bahex
79a6c78032 implement FromValue for std::time::Duration and refactor relevant commands to utilize that (#16414)
# Description

- Implemented `FromValue` for `std::time::Duration`.
- It only converts positive `Value::Duration` values, negative ones
raise `ShellError::NeedsPositiveValue`.
- Refactor `job recv` and `watch` commands to use this implementation
rather than handling it ad-hoc.
- Simplified `watch`'s `debounce` & `debounce-ms` and factored it to a
function. Should make removing `debounce-ms` after its deprecation
period ends.
- `job recv` previously used a numeric cast (`i64 as u64`) which would
result in extremely long duration values rather than raising an error
when negative duration arguments were given.

# User-Facing Changes

Changes in error messages:
- Providing the wrong type (bypassing parse time type checking):
  - Before
    ```
    Error: nu:🐚:type_mismatch

      × Type mismatch.
       ╭─[entry #40:1:9]
     1 │ watch . --debounce (1 | $in) {|| }
       ·         ──────────┬─────────
       ·                   ╰── Debounce duration must be a duration
       ╰────
    ```
  - After
    ```
    Error: nu:🐚:cant_convert

      × Can't convert to duration.
       ╭─[entry #2:1:9]
     1 │ watch . --debounce (1 | $in) {|| }
       ·         ──────────┬─────────
       ·                   ╰── can't convert int to duration
       ╰────
    ```
- Providing a negative duration value:
  - Before
    ```
    Error: nu:🐚:type_mismatch

      × Type mismatch.
       ╭─[entry #41:1:9]
     1 │ watch . --debounce -100ms {|| }
       ·         ────────┬────────
       ·                 ╰── Debounce duration is invalid
       ╰────
    ```
  - After
    ```
    Error: nu:🐚:needs_positive_value

      × Negative value passed when positive one is required
       ╭─[entry #4:1:9]
     1 │ watch . --debounce -100ms {|| }
       ·         ────────┬────────
       ·                 ╰── use a positive value
       ╰────
    ```
2025-08-12 22:25:23 +02:00
Bahex
5478bdff0e feat: null values can be spread as if they are empty lists or records. (#16399)
# Description
Spread operator `...` treats `null` values as empty collections,
, whichever of list or record is appropriate.

# User-Facing Changes
`null` values can be used with the spread operator (`...`)
2025-08-11 23:47:31 +03:00
Bahex
a4711af952 feat: impl<B> for (From/Into)Value for Cow<'_, B> where B::Owned: (From/Into)Value (#16380)
# Description
Implements `FromValue` and `IntoValue` for `Cow`, which makes it easy to
use it in types that need to implement these traits.

I don't think it will have a significant impact, but it can let us avoid
allocations where we can use static values.

# Tests + Formatting
No need, the implementations are delegated to `B::Owned`.

Co-authored-by: Bahex <Bahex@users.noreply.github.com>
2025-08-11 19:47:50 +02:00
Andrej Kolčin
751ef6e8da [parser] Improve type errors for boolean literals (#16408)
Currently, strings `true` and `false` are intercepted early in parsing.
Previously, if they didn't match the expected shape, the parse error
said "expected non-boolean value". This PR changes the message to say
"expected <shape>".

Because the parsing error requires a `&'static str` I had to add a
`to_str(&self) -> &'static str` method on `SyntaxShape`. It's a bit
crude for more complex shapes: it simply says `keyword`, `list`,
`table`, and so on for them, without exposing the underlying structure.

Fixes #16406
2025-08-11 11:59:27 -05:00
Ecorous
038f8f85ed Fix missing $env.PATH unhelpful error and breaking CMD builtins (#16410)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->
Fixes #16409 

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
After running `hide-env PATH`, there is a more helpful error and CMD
builtins still work.
<img width="503" height="217" alt="image"
src="https://github.com/user-attachments/assets/a43180f9-5bc2-43bd-9773-aa9ad1818386"
/>
<img width="779" height="253" alt="image"
src="https://github.com/user-attachments/assets/03b59209-f9a9-4c61-9ea2-8fbdc27b8d4b"
/>


# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

---------

Co-authored-by: 132ikl <132@ikl.sh>
2025-08-11 12:55:22 -04:00
Ecorous
4245c67ce3 Add --raw flag to to html (#16373)
Works towards #16347 however more work may be required first

# Description
Adds a `--raw` flag to `to html`. This stops the resulting html content
being escaped
# User-Facing Changes

# Tests + Formatting
# After Submitting
2025-08-11 21:31:24 +08:00