Commit Graph

9959 Commits

Author SHA1 Message Date
Douglas
5d1e2b1df1
Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00
Nguyễn Hồng Quân
273226d666
Provide more directories autocomplete for "overlay use" (#15057)
## Description

- Fixes #12891
- An escape for #12835

Currently, Nushell is not very friendly to Python workflow, because
Python developers very often need to activate a virtual environment, and
in some workflow, the _activate.nu_ script is not near to "current
working directory" (especially ones who use
[virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/)
and [Poetry](https://python-poetry.org/)), and hence, is not
auto-completed for `overlay use`.
Though Nu v0.102.0 has improved auto-complete for `overlay use`, it
doesn't work if user starts the file path with `~` or `/`, like:

```nu
> overlay use /h
```
```nu
> overlay use ~/W
```

### Before:


![image](https://github.com/user-attachments/assets/8b668c21-0f3a-4d6f-9cd2-8cc92460525c)

### After:


![image](https://github.com/user-attachments/assets/ca491e64-774a-48d4-8f4f-58d647e011df)


![image](https://github.com/user-attachments/assets/4e097008-b5e1-4f63-af80-c1697025d4ad)



## User-Facing Changes

No

## Tests + Formatting

Passed

---------

Co-authored-by: blindfs <blindfs19@gmail.com>
2025-02-17 12:52:07 -05:00
Douglas
2b8fb4fe00
Fix failing test when using man version 2.13.0 (#15123)
The test added in #15115 fails on systems using later versions of `man`
(2.13.0 triggers the issue, at least). This updates the test to ignore
formatting characters.

Thanks to @fdncred and @blindFS for the debugging assistance.
2025-02-15 18:55:33 -05:00
Douglas
2cb059146b
Add buffer_editor example with arguments in config nu --doc (#15122)
Counterpart to https://github.com/nushell/nushell.github.io/pull/1810 -
Adds an example to the `config nu --doc` for using a `buffer_editor`
with arguments.

Closes https://github.com/nushell/nushell.github.io/issues/1660 and
resolves the main issue in #14893, but we'll leave it open based on
[this
suggestion](https://github.com/nushell/nushell/issues/14893#issuecomment-2607670442)
2025-02-14 18:51:54 -05:00
zc he
fb7b0a8c11
feat(lsp): hover on external command shows manpage (#15115)
# Description

<img width="642" alt="image"
src="https://github.com/user-attachments/assets/a97e4f33-df12-4240-a221-d4b97a171de0"
/>

Not particularly useful, but better than showing nothing I guess. #14464

Also fixed a markdown syntax issue for mutable variable hovering

# User-Facing Changes

# Tests + Formatting

+1

# After Submitting

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2025-02-14 10:59:46 -06:00
Douglas
d4aeadbb44
Enable theming the Welcome Banner (#15095)
The banner will now use three new `$env.config.color_config` settings:
- `banner_foreground`: The primary color of the banner text
- `banner_highlight1`: Used for the first set of highlights, e.g.,
`Nushell`, `nu`, `GitHub`, et. al
- `banner_highlight2`: Used for the second set of highlights, e.g.
`Discord`, `Documentation`, et. al.

If the settings above are not defined, `banner` continues to use the
default green/purple/foreground. However, two more lines use the
purple/highlight2 in order to give more separation and consistency to
the colorization.
2025-02-14 10:19:16 -05:00
Bahex
2a8f92b709
docs(chunks): make chunks easier to discover for binary data (#15117)
# Description
There has been multiple instances of users being unable to discover that
`chunks` can be used with binary data.
This should make it easier for users to discover that (using `help -f`).

# User-Facing Changes
Help text of `chunks` updated as mentioned above.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting

Should we consider mentioning commands that can work with binary input
(first, take, chunks, etc) in the help text for `bytes`?

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-02-14 06:29:45 -06:00
Justin Ma
453e294883
Refactor kv commands: replace inline params in SQL queries (#15108)
# Description

Update some comments and fix potential security issue:

SQL Injection in DELETE statements: The code constructs SQL queries by
interpolating the $key variable directly into the string. If a key
contains malicious input could lead to SQL injection. Need to use
parameterized queries or escaping.
2025-02-13 23:23:59 -05:00
Bahex
e1c5ae3cd5
fix(test stdlib): scanning tests shouldn't be affected by user config (#15113)
# Description

# User-Facing Changes

# Tests + Formatting

# After Submitting

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-02-13 20:23:14 +01:00
Stefan Holderbach
a8a0c78a32
Bump Ubuntu runners to 22.04 LTS for tests (#15109)
The release workflow is already on 22.04 for a while. But our tests
where still with 20.04 which is close to end of life

Closes #15052
2025-02-13 16:51:21 +01:00
Stefan Holderbach
879258039c
Revert / vi binding due to priority bug (#15111)
Manually added bindings take priority to the vi-mode state machine in
reedline thus this addition blocked the use of `f/`/`t/` etc.

Partial revert of #14908

Addresses #15096 with a temporary fix. The full solution of that should
resolve it on the reedline side so you can have both the search option
and the availability of `/` in normal mode bindings
2025-02-13 16:29:08 +01:00
Bahex
4ac4f71a37
feat(overlay): expose constants with overlay use (#15081)
# Description

`overlay use` now imports constants exported from modules, just like
`use`.

```nushell
# foo.nu
export const a = 1
export const b = 2
```

- `overlay use foo.nu` being equivalent to `use foo.nu *` and exposing
constants `$a = 1` and `$b = 2`
- `overlay use foo.nu -p` being equivalent to `use foo.nu` and exposing
the constant `$foo = {a: 1, b: 2}`

# User-Facing Changes

`overlay use` now imports constants just like `use`.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A
2025-02-13 18:55:03 +08:00
Ian Manske
62e56d3581
Rework operator type errors (#14429)
# Description

This PR adds two new `ParseError` and `ShellError` cases for type errors
relating to operators.
- `OperatorUnsupportedType` is used when a type is not supported by an
operator in any way, shape, or form. E.g., `+` does not support `bool`.
- `OperatorIncompatibleTypes` is used when a operator is used with types
it supports, but the combination of types provided cannot be used
together. E.g., `filesize + duration` is not a valid combination.

The other preexisting error cases related to operators have been removed
and replaced with the new ones above. Namely:

- `ShellError::OperatorMismatch`
- `ShellError::UnsupportedOperator`
- `ParseError::UnsupportedOperationLHS`
- `ParseError::UnsupportedOperationRHS`
- `ParseError::UnsupportedOperationTernary`

# User-Facing Changes

- `help operators` now lists the precedence of `not` as 55 instead of 0
(above the other boolean operators). Fixes #13675.
- `math median` and `math mode` now ignore NaN values so that `[NaN NaN]
| math median` and `[NaN NaN] | math mode` no longer trigger a type
error. Instead, it's now an empty input error. Fixing this in earnest
can be left for a future PR.
- Comparisons with `nan` now return false instead of causing an error.
E.g., `1 == nan` is now `false`.
- All the operator type errors have been standardized and reworked. In
particular, they can now have a help message, which is currently used
for types errors relating to `++`.

```nu
[1] ++ 2
```
```
Error: nu::parser::operator_unsupported_type

  × The '++' operator does not work on values of type 'int'.
   ╭─[entry #1:1:5]
 1 │ [1] ++ 2
   ·     ─┬ ┬
   ·      │ ╰── int
   ·      ╰── does not support 'int'
   ╰────
  help: if you meant to append a value to a list or a record to a table, use the `append` command or wrap the value in a list. For example: `$list ++ $value` should be
        `$list ++ [$value]` or `$list | append $value`.
```
2025-02-12 20:03:40 -08:00
Bahex
2e1b6acc0e
feat(const): implement run_const for const (#15082)
- fixes #14559

# Description
Allow using `const` keyword in const contexts. The `run_const` body is
basically empty as the actual logic is already handled by the parser.

# User-Facing Changes
`const` keyword can now be used in `const` contexts.

# Tests + Formatting

I'll add some tests before marking this ready. 

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A

---------

Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
2025-02-12 16:59:51 +01:00
Douglas
3eae657121
Update std-rfc tests for to use @test attributes (#15098)
After #14906, the test runner was updated to use attributes, along with
the existing `std` modules. However, since that PR was started before
`std-rfc` was in main, it didn't include updates to those tests. Once
#14906 was merged, the `std-rfc` tests no longer ran in CI. This PR
updates the tests accordingly.
2025-02-12 06:48:41 -05:00
dependabot[bot]
e74ce72f09
build(deps): bump data-encoding from 2.7.0 to 2.8.0 (#15101)
Bumps [data-encoding](https://github.com/ia0/data-encoding) from 2.7.0
to 2.8.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="284f84626a"><code>284f846</code></a>
Release 2.8.0 (<a
href="https://redirect.github.com/ia0/data-encoding/issues/134">#134</a>)</li>
<li><a
href="b6f9f3b9d6"><code>b6f9f3b</code></a>
Remove MSRV for unpublished crates (<a
href="https://redirect.github.com/ia0/data-encoding/issues/133">#133</a>)</li>
<li><a
href="c060e6873c"><code>c060e68</code></a>
Delete outdated cargo cache to force save (<a
href="https://redirect.github.com/ia0/data-encoding/issues/132">#132</a>)</li>
<li><a
href="d62d722222"><code>d62d722</code></a>
Remove top-level Makefile (<a
href="https://redirect.github.com/ia0/data-encoding/issues/131">#131</a>)</li>
<li><a
href="5e86676a34"><code>5e86676</code></a>
Improve CI workflow (<a
href="https://redirect.github.com/ia0/data-encoding/issues/130">#130</a>)</li>
<li><a
href="8a9537cf64"><code>8a9537c</code></a>
Improve fuzzing (<a
href="https://redirect.github.com/ia0/data-encoding/issues/129">#129</a>)</li>
<li><a
href="27a68f43cd"><code>27a68f4</code></a>
Add missing safety documentation and assertions for testing and fuzzing
(<a
href="https://redirect.github.com/ia0/data-encoding/issues/128">#128</a>)</li>
<li><a
href="06b0d89b11"><code>06b0d89</code></a>
Add BASE32_NOPAD_NOCASE and BASE32_NOPAD_VISUAL (<a
href="https://redirect.github.com/ia0/data-encoding/issues/127">#127</a>)</li>
<li>See full diff in <a
href="https://github.com/ia0/data-encoding/compare/v2.7.0...v2.8.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=data-encoding&package-manager=cargo&previous-version=2.7.0&new-version=2.8.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-12 12:45:27 +08:00
Bahex
d577074da9
feat(std/dirs): retain state in subshells or with exec-restarts (#15080)
Persist `std/dirs`'s state in subshells and also when restarting the
shell with `exec $nu.current-exe`
2025-02-11 19:51:43 -05:00
Bahex
f7d5162582
docs(std-rfc): use actual examples rather than doc comments (#15097)
# Description
Update examples with attributes.

# User-Facing Changes
`std-rfc` commands now have examples.

# Tests + Formatting
N/A

# After Submitting
N/A
2025-02-11 16:33:27 -06:00
Piepmatz
0430167f1c
Use proc-macro-error2 instead of proc-macro-error (#15093)
<!--
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!
-->

# 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.
-->

This PR replaces the usage of `proc-macro-error` with
`proc-macro-error2`. At the time of writing `nu-derive-value` this
wasn't an option, at least it wasn't clear that it is the direction to
go. This shouldn't change any of the usage of `nu-derive-value` in any
way but removes one security warning.

`proc-macro-error` depends on `syn 1`, that's why I initially had the
default features for `proc-macro-error` disabled. `proc-macro-error2`
uses `syn 2` as mostly everything. So we can use that.

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

Same interface, no 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
> ```
-->

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

The tests for `nu-derive-value` do not test spans, so maybe something
changed now but probably not.

# 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.
-->

We still have `quickcheck` which depends on `syn 1` but it seems we need
that for `nu-cmd-lang`. Would be great if, in the future, we can get rid
of `syn 1` as that should improve build times a bit.
2025-02-11 15:13:34 -05:00
Yash Thakur
1128fa137f
Fix spread operator lexing in records (#15023)
# Description

Zyphys found that when parsing `{...{}, ...{}, a: 1}`, the `a:` would be
considered one token, leading to a parse error ([Discord
message](https://discord.com/channels/601130461678272522/614593951969574961/1336762075535511573)).
This PR fixes that.

What would happen is that while getting tokens, the following would
happen in a loop:
1. Get the next two tokens while treating `:` as a special character (so
we get the next field key and a colon token)
2. Get the next token while not treating `:` as a special character (so
we get the next value)

I didn't update this when I added the spread operator. With `{...{},
...{}, a: 1}`, the first two tokens would be `...{}` and `...{}`, and
the next token would be `a:`. This PR changes this loop to first get a
single token, check if it's spreading a record, and move on if so.

Alternatives considered:
- Treat `:` as a special character when getting the value too. This
would simplify the loop greatly, but would mean you can't use colons in
values.
- Merge the loop for getting tokens and the loop for parsing those
tokens. I tried this, but it complicates things if you run into a syntax
error and want to create a garbage span going to the end of the record.

# User-Facing Changes

Nothing new
2025-02-11 09:51:34 -05:00
Wind
81243c48f0
make plugin compatible with nightly nushell version (#15084)
# Description
Close: #15083

This pr will set `pre` field of version to `Prerelease::EMPTY`, as
nushell does not require this level of checking currently.

# User-Facing Changes
NaN

# Tests + Formatting
Added 1 test

# After Submitting
NaN
2025-02-11 06:40:15 -06:00
Bahex
442df9e39c
Custom command attributes (#14906)
# Description
Add custom command attributes.

- Attributes are placed before a command definition and start with a `@`
character.
- Attribute invocations consist of const command call. The command's
name must start with "attr ", but this prefix is not used in the
invocation.
- A command named `attr example` is invoked as an attribute as
`@example`
-   Several built-in attribute commands are provided as part of this PR
    -   `attr example`: Attaches an example to the commands help text
        ```nushell
        # Double numbers
        @example "double an int"  { 5 | double }   --result 10
        @example "double a float" { 0.5 | double } --result 1.0
        def double []: [number -> number] {
            $in * 2
        }
        ```
    -   `attr search-terms`: Adds search terms to a command
    -   ~`attr env`: Equivalent to using `def --env`~
- ~`attr wrapped`: Equivalent to using `def --wrapped`~ shelved for
later discussion
    -   several testing related attributes in `std/testing`
- If an attribute has no internal/special purpose, it's stored as
command metadata that can be obtained with `scope commands`.
- This allows having attributes like `@test` which can be used by test
runners.
-   Used the `@example` attribute for `std` examples.
-   Updated the std tests and test runner to use `@test` attributes
-   Added completions for attributes

# User-Facing Changes
Users can add examples to their own command definitions, and add other
arbitrary attributes.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
- Add documentation about the attribute syntax and built-in attributes
- `help attributes`

---------

Co-authored-by: 132ikl <132@ikl.sh>
2025-02-11 06:34:51 -06:00
Stefan Holderbach
a58d9b0b3a
Refactor/fix tests affecting the whole command set (#15073)
# Description
Pre-cratification of `nu-command` we added tests that covered the whole
command set to ensure consistent documentation style choices and that
the search terms which are added are not uselessly redundant. These
tests are now moved into the suite of the main binary to truly cover all
commands.

- **Move parser quickcheck "fuzz" to `nu-cmd-lang`**
- **Factor out creation of full engine state for tests**
- **Move all-command tests to main context creation**
- **Fix all descriptions**
- **Fix search term duplicate**

# User-Facing Changes
As a result I had to fix a few command argument descriptions. (Doesn't
mean I fully stand behind this choice, but) positionals
(rest/required/optional) and top level descriptions should start with a
capital letter and end with a period. This is not enforced for flags.

# Tests + Formatting
Furthermore I moved our poor-peoples-fuzzer that runs in CI with
`quicktest` over the parser to `nu-cmd-lang` reducing its command set to
just the keywords (similar to
https://github.com/nushell/nushell/pull/15036). Thus this should also
run slightly faster (maybe a slight parallel build cost due to earlier
dependency on quicktest)
2025-02-11 11:36:36 +01:00
Stefan Holderbach
2a3d5a9d42
Bump bytesize to fix into filesize (#15088)
# Description
Closes https://github.com/nushell/nushell/issues/14866

Incorporates https://github.com/bytesize-rs/bytesize/pull/59 with
bytesize version 1.3.1

# User-Facing Changes
Now rejected strings
```
"1.3 1.3 kB" | into filesize
"1 420 kB" | into filesize
```
# Tests + Formatting
Added test with invalid input that was silently ignored before
2025-02-11 11:33:48 +01:00
Stefan Holderbach
a5d7d6dd46
Bump yanked dependencies (#15090)
Seen in the `cargo install --locked` step of the stdlib ci
- `scc`
- `sdd` [according to changelog potential use after
free](https://github.com/wvwwvwwv/scalable-delayed-dealloc/blob/main/CHANGELOG.md)

Should only be part of the `dev-dependencies` due to `serial_test`
2025-02-11 11:33:29 +01:00
Stefan Holderbach
18e3a5d40b
Fix match blocks in std-rfc/kv implementation (#15089)
Fixes failure surfaced by merging
https://github.com/nushell/nushell/pull/15032
2025-02-11 11:16:57 +01:00
132ikl
553c951a60
Fix match running closures as block (#15032)
# Description
This PR makes `match` no longer run closures as if they were blocks.
This also allows returning closures from `match` without needing to wrap
in an outer subexpression or block.

Before PR:
```nushell
match 1 { _ => {|| print hi} }
# => hi
```

After PR:
```nushell
match 1 { _ => {|| print hi} }
# => closure_1090
```

# User-Facing Changes

* `match` no longer runs closures as if they were blocks

# Tests + Formatting

N/A

# After Submitting

N/A
2025-02-11 10:35:23 +01:00
Bahex
781c4bd1d7
use 0-indexing in explore (#15079)
# Description
The index in `explore --index` starting with 1 is inconsistent with rest
of nushell. Also it tripped me up a few times when I wanted to select a
row with `:nu get n`

# User-Facing Changes
Index in `explore --index` now starts with 0.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A
2025-02-10 15:26:42 -06:00
Bahex
a2e335dcd7
fix block spans for the module keyword (#15078)
# Description
I noticed that the following code snippet wasn't being highlighted
correctly. Spans used for parsing contents of the block was also
incorrectly used for the expression.

# User-Facing Changes
The block following the module keyword is now highlighted correctly.

| Before | After |
|--------|--------|
|
![image](https://github.com/user-attachments/assets/8d1040f5-5002-4880-bb71-47549a67a804)
|
![image](https://github.com/user-attachments/assets/0dc28e25-2da3-4411-82ae-3e4e129fd42f)
|

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A
2025-02-10 15:26:02 -06:00
zc he
c6fc6bd5a7
fix(lsp): inlay hints span issue with user config scripts (#15071)
# Description

Fixes this:

![image](https://github.com/user-attachments/assets/98b523dd-df30-4e85-b069-20aaad0d9bf5)

# User-Facing Changes

# Tests + Formatting

I can't figure out how to test this atm.
Happy to do it if someone show me some hints how.

# After Submitting
2025-02-10 16:15:03 +01:00
Douglas
a7830ac1fd
Update README.md
Fix link
2025-02-10 09:06:09 -05:00
Douglas
00713c9339
Update README.md
Fix Drawing-Board link/description
2025-02-10 09:05:05 -05:00
Wind
7d7dbd8b2c
Fix missing required overlay error (#15058)
# Description
Fixes: #15049

The error occurs when using an alias with a module prefix, it can
initially pass through alias checking, but if the alias leads to
commands which have side effects, it doesn't call these functions to
apply side effects.
This pr ensure that in such cases, nushell still calls
`parse_overlay_xxx` functions to apply the side effects.

I want to make my test easier to write, so this pr depends on
https://github.com/nushell/nushell/pull/15054.

# User-Facing Changes
The following code will no longer raise an error:
```
module inner {}
module spam { export alias b = overlay use inner }
use spam
spam b
```

# Tests + Formatting
Added 2 tests.

# After Submitting
NaN
2025-02-10 16:27:50 +08:00
Wind
d4675d9138
allow export alias in repl (#15054)
# Description
Fixes: #15048
The issue is happened while `parse_export_in_block`, it makes a call to
`parse_internal_call`, which may be an error.
But in reality, these errors are not useful, all useful errors will be
generated by `parse_xxx` at the end of the function.

# User-Facing Changes
The following code should no longer raise error:
```
export alias a = overlay use
```

# Tests + Formatting
Added 1 test.

# After Submitting
NaN
2025-02-10 15:32:05 +08:00
zc he
6e88b3f8d6
refactor(completion): expression based variable/cell_path completion (#15033)
# Description

fixes #14643 , as well as some nested cell path cases:

```nushell
let foo = {a: [1 {a: 1}]}

$foo.a.1.#<tab>

const bar = {a: 1, b: 2}
$bar.#<tab>
```

So my plan of the refactoring process is that:
1. gradually move those rules of flattened shapes into expression match
branches, until they are gone
2. keep each PR focused, easier to review and track. 

# User-Facing Changes

# Tests + Formatting

+2

# After Submitting
2025-02-09 22:26:41 -05:00
Douglas
720813339f
Add std-rfc README (#15066)
Copied the old README from `nu_scripts/stdlib-candidate/std-rfc` over to `nu-std/std-rfc` and
updated it with the latest info.
2025-02-09 11:21:56 -05:00
Douglas
5b4dd775d4
Move std-rfc into Nushell (#15042)
Move `std-rfc` into Nushell.  `use std-rfc/<submodule>` now works "out-of-the-box"
2025-02-09 09:03:37 -05:00
Douglas
bfe398ca36
Fix char lsep assignment (#15065)
Fix `char eol` issue where there was still a hardcoded `\n` taking
effect on Windows.
2025-02-09 07:19:11 -05:00
Solomon
31e1f49cb6
fix ranges over zero-length input (#15062)
Fixes #15061

# User-Facing Changes

Fixes panics when slicing empty input with inclusive ranges:

```nushell
> random binary 0 | bytes at 0..0
Error:   x Main thread panicked.
  |-> at crates/nu-protocol/src/value/range.rs:118:42
  `-> attempt to subtract with overflow
```
2025-02-08 19:57:28 -05:00
Douglas
26897b287c
Adds platform agnostic EoL separator to char command (#15059)
Adds `char eol`, `char line_sep`, and `char lsep` (synonyms) to represent
the platform specific line ending character(s).
2025-02-08 16:23:51 -05:00
Douglas
5a7707cb52
Remove --no-default-features for std-lib-and-python-virtualenv CI (#15045)
# Description

Current CI tests `std-lib-and-python-virtualenv` using Nushell installed
with:

```
cargo install --path . --locked --no-default-features --force
```

However, this disables certain features that may be utilized in `std` or
(now) `std-rfc`; namely `stor` and `into sqlite`.

This PR simply removes the `--no-default-features` flag, which *should*
allow #15042 CI to complete successfully.

Historically, I believe that this was set up to mirror
[`pypa/virtualenv`
CI](https://github.com/pypa/virtualenv/pulls?q=is%3Apr+is%3Amerged+nushell).
However, with all Nushell binary builds now including these features, it
seems to me that a more accurate CI will test with default features. Let
me know if my understanding is off here, and we can look for
alternatives.

# User-Facing Changes

None

# Tests + Formatting

CI Update

# After Submitting

N/A
2025-02-08 21:02:15 +02:00
Piepmatz
4b0b4ddce1
Replaced IoError::new_with_additional_context calls that still had Span::unknown() (#15056)
<!--
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!
-->

# 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.
-->
In #14968 I grepped the code for `IoError::new` calls with unknown
spans, but I forgot to also grep for
`IoError::new_with_additional_context`, so I missed some. Hopefullly
this is the last P.S. to #14968.

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

N/A

# 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
> ```
-->

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# 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.
-->

N/A
2025-02-08 09:23:28 -06:00
zc he
9fa2f43d06
fix(lsp): exit on null root_dir (#15051)
# Description

This PR fixes one reported bug of recent lsp changes.

It exit unexpectedly with empty `root_dir` settings in neovim.

# User-Facing Changes

# Tests + Formatting

+1 test case

# After Submitting
2025-02-08 06:49:38 -06:00
Stefan Holderbach
2891867de9
Trigger tests for patch release branch pushes (#15037)
Make sure that when creating a cherry-picked or otherwise diverging
patch release branch the final product still gets checked via CI before
a release is cut.

To trigger this patch release branches MUST follow the pattern:
`patch-release-*` (e.g. `patch-release-0.102.1`)
2025-02-07 23:51:01 +01:00
Stefan Holderbach
55c7246830
Fuzz more realistically with keyword const eval (#15036)
# Description
The parsing logic for several of our keywords is conditional on the
particular commands for those keywords being in scope:


942030199d/crates/nu-parser/src/parse_keywords.rs (L272-L279)

Thus the following involved parsing logic was not fuzzed by the existing
`parse` fuzz target so far.

This adds an additional fuzz target `parse_with_keywords` that loads the
commands from `nu-cmd-lang`. Those are primarily the keyword
implementations, thus the relevant code paths in the parser that depend
on those `DeclId`s and the potential const eval of `if` etc. get
unlocked.

The existing `parse` target is preserved if you have concerns about the
fuzzing breaking containment in some form due to those commands.

# Tests + Formatting
Found https://github.com/nushell/nushell/issues/14972 with this target
2025-02-07 23:50:47 +01:00
Stefan Holderbach
17246db38b
Fix usages of fmt to format number (#15041)
Those slipped through the cracks with
https://github.com/nushell/nushell/pull/14875

Avoids deprecation warning and failure after
https://github.com/nushell/nushell/pull/15040
2025-02-07 23:50:33 +01:00
Solomon
e60dac8957
remove nu-check examples with the --all flag (#15047)
# Description

Deletes example usage of `nu-check`'s `--all` flag, which was removed in
5e937ca1af.
2025-02-07 14:31:59 -06:00
Stefan Holderbach
d007b10fbf
Use build_target information in startup banner (#15046)
# Description
The `(version).build_os` variable inherits from `shadow_rs` `BUILD_OS`
which points to the OS on which the binary was built but does not
reflect the target if it was cross-compiled. We cross-compile several of
the targets for our binary releases. Thus the info in the banner was
misleading.

# User-Facing Changes
By changing to `build_target` the target triple is shown instead.
This is slightly more verbose but should also allow disambiguation
between the `musl` and `glibc` builds.


![grafik](https://github.com/user-attachments/assets/24dd43d7-9717-463b-809b-b81b44f9ab52)

# Tests + Formatting
(-)
2025-02-07 12:10:13 -06:00
Solomon
942030199d
check signals while printing values (#14980)
Fixes #14960

# User-Facing Changes

- The output of non-streaming values can now be interrupted with ctrl-c:

```nushell
~> use std repeat; random chars --length 100kb | repeat 2000 | str join ' ' | collect
<data omitted>^C
Error:
  × Operation interrupted
   ╭─[entry #1:1:61]
 1 │ use std repeat; random chars --length 100kb | repeat 2000 | str join ' ' | collect
   ·                                                             ────┬───
   ·                                                                 ╰── This operation was interrupted
   ╰────
```

- When IO errors occur while printing data, nushell no longer panics:

```diff
 $ nu -c "true | print" | -

-Error:
-  x Main thread panicked.
-  |-> at crates/nu-protocol/src/errors/shell_error/io.rs:198:13
-  `-> for unknown spans with paths, use `new_internal_with_path`
+Error: nu:🐚:io::broken_pipe
+
+  x I/O error
+  `->   x Broken pipe
+
+   ,-[source:1:1]
+ 1 | true | print
+   : ^^|^
+   :   `-| Writing to stdout failed
+   :     | Broken pipe
+   `----
```
2025-02-07 06:56:07 -05:00
zc he
fb8ac4198b
fix: clippy warnings with --all-features (#15035)
# Description

Some more `cargo clippy --all-features` warnings from rust toolchain
1.84.1 that I forgot to fix in #14984
2025-02-07 12:30:25 +01:00