Commit Graph

9407 Commits

Author SHA1 Message Date
Wind
183c2221bb
Removes more quotes on external command arguments (#13883)
# Description
Fixes: #13662

I don't think nushell need to parse and keep nested quote on external
command arguments. Some nested quote is safe to removed. After the pr,
nushell will behave more likely to bash.

# User-Facing Changes
#### Before
```
> ^echo {a:1,b:'c',c:'d'}
{a:1,b:c',c:'d} 
```
#### After
```
> ^echo {a:1,b:'c',c:'d'}
{a:1,b:c,c:d}
```

# Tests + Formatting
Added some tests to cover the behavior
2024-09-23 06:44:51 -05:00
Ian Manske
03ee54a4df
Fix try not working with let, etc. (#13885)
# Description
Partialy addresses #13868. `try` does not catch non-zero exit code
errors from the last command in a pipeline if the result is assigned to
a variable using `let` (or `mut`).

This was fixed by adding a new `OutDest::Value` case. This is used when
the pipeline is in a "value" position. I.e., it will be collected into a
value. This ended up replacing most of the usages of `OutDest::Capture`.
So, this PR also renames `OutDest::Capture` to `OutDest::PipeSeparate`
to better fit the few remaining use cases for it.

# User-Facing Changes
Bug fix.

# Tests + Formatting
Added two tests.
2024-09-23 06:44:25 -05:00
Jack Wright
2541a712e4
Added polars concat to allow concatenation of multiple dataframes (#13879)
# Description
Provides the ability to concatenate multiple dataframes together

# User-Facing Changes
- Introduces new command `polars concat`
2024-09-23 06:43:43 -05:00
Darren Schroeder
ee877607fb
fix the ability to add a plugin by name instead of path (#13877)
# Description

This plugin fixes the ability to do `plugin add nu_plugin_polars` and
have nushell look in NU_PLUGINS_DIR to find the plugin and add it.

closes #13040

# 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.
-->
2024-09-23 06:43:19 -05:00
Bahex
93351b889a
view source: add content_type metadata (#13859)
# Description
Add content type metadata to the output of `view source`.

I've gone along with the mime type used [here][xdg], but this shouldn't
be merged until there is consensus #13858.

`to nuon`'s output has content type `application/x-nuon`

[xdg]:
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/231

# User-Facing Changes
Combined with `metadata access`, allows richer display_output hooks.
Might be useful with other commands that make use of content_type like
the `http` commands.
2024-09-23 06:42:52 -05:00
Skyler Hawthorne
5fa9d76500
polars: add binary type support (#13830)
# Description
This adds support for reading and writing binary types in the polars
commands.

The `BinaryOffset` type can be read into a Nushell native `Value` type
no problem, but unfortunately this is a lossy conversion, as there's
no Nushell-native semantic equivalent to the fixed size binary type
in Arrow.

# User-Facing Changes

`polars open` and `polars save` now work with binary types.
2024-09-23 06:28:41 -05:00
Ian Manske
cd0d0364ec
Fix do -p not waiting for external commands (#13881)
# Description
Similar to #13870 (thanks @WindSoilder), this PR adds a boolean which
determines whether to ignore any errors from an external command. This
is in order to fix #13876. I.e., `do -p` does not wait for externals to
complete before continuing.

# User-Facing Changes
Bug fix.

# Tests + Formatting
Added a test.
2024-09-22 22:26:32 +08:00
Justin Ma
cf5fec63c0
Add loongarch64-unknown-linux-gnu-gcc build target (#13895)
# Description

Add `loongarch64-unknown-linux-gnu-gcc` build target
A test release could be found here:
https://github.com/nushell/nightly/releases/tag/v0.98.1
Loongarch64 workflow build result:
https://github.com/nushell/nightly/actions/runs/10973523602/job/30471006104
2024-09-22 17:20:15 +08:00
dependabot[bot]
5c5cf418fb
Bump crate-ci/typos from 1.24.5 to 1.24.6 (#13864)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.24.5 to
1.24.6.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/crate-ci/typos/releases">crate-ci/typos's
releases</a>.</em></p>
<blockquote>
<h2>v1.24.6</h2>
<h2>[1.24.6] - 2024-09-16</h2>
<h3>Fixes</h3>
<ul>
<li>Respect negation (<code>!</code>) in
<code>extend-exclude</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/crate-ci/typos/blob/master/CHANGELOG.md">crate-ci/typos's
changelog</a>.</em></p>
<blockquote>
<h2>[1.24.6] - 2024-09-16</h2>
<h3>Fixes</h3>
<ul>
<li>Respect negation (<code>!</code>) in
<code>extend-exclude</code></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8e6a4285bc"><code>8e6a428</code></a>
chore: Release</li>
<li><a
href="cab7c3c4a5"><code>cab7c3c</code></a>
docs: Update changelog</li>
<li><a
href="c4a6592239"><code>c4a6592</code></a>
Merge pull request <a
href="https://redirect.github.com/crate-ci/typos/issues/1100">#1100</a>
from epage/invert</li>
<li><a
href="ad3538f719"><code>ad3538f</code></a>
refactor(cli): Switch from Overrides to Gitignore</li>
<li><a
href="d9b55f966c"><code>d9b55f9</code></a>
fix(cli): Allow negative expressions in extend-exclude</li>
<li><a
href="777cf42dc2"><code>777cf42</code></a>
refactor(cli): Be explicit in overrides</li>
<li><a
href="0e8148fbbd"><code>0e8148f</code></a>
test(cli): Show inverted extend-exclude behavior</li>
<li>See full diff in <a
href="https://github.com/crate-ci/typos/compare/v1.24.5...v1.24.6">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=crate-ci/typos&package-manager=github_actions&previous-version=1.24.5&new-version=1.24.6)](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>
2024-09-22 15:16:28 +08:00
dependabot[bot]
fb14008f50
Bump shadow-rs from 0.34.0 to 0.35.0 (#13863)
Bumps [shadow-rs](https://github.com/baoyachi/shadow-rs) from 0.34.0 to
0.35.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/baoyachi/shadow-rs/releases">shadow-rs's
releases</a>.</em></p>
<blockquote>
<h2>v0.35.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Update time crate by <a
href="https://github.com/diniamo"><code>@​diniamo</code></a> in <a
href="https://redirect.github.com/baoyachi/shadow-rs/pull/182">baoyachi/shadow-rs#182</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/diniamo"><code>@​diniamo</code></a> made
their first contribution in <a
href="https://redirect.github.com/baoyachi/shadow-rs/pull/182">baoyachi/shadow-rs#182</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/baoyachi/shadow-rs/compare/v0.34.0...v0.35.0">https://github.com/baoyachi/shadow-rs/compare/v0.34.0...v0.35.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="4358b4a094"><code>4358b4a</code></a>
Update Cargo.toml</li>
<li><a
href="2851d669dd"><code>2851d66</code></a>
Merge pull request <a
href="https://redirect.github.com/baoyachi/shadow-rs/issues/182">#182</a>
from diniamo/update-time</li>
<li><a
href="e77dcef733"><code>e77dcef</code></a>
Update time crate</li>
<li>See full diff in <a
href="https://github.com/baoyachi/shadow-rs/compare/v0.34.0...v0.35.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=shadow-rs&package-manager=cargo&previous-version=0.34.0&new-version=0.35.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>
2024-09-22 15:16:20 +08:00
dependabot[bot]
18c8c16c5e
Bump unicode-segmentation from 1.11.0 to 1.12.0 (#13862)
Bumps
[unicode-segmentation](https://github.com/unicode-rs/unicode-segmentation)
from 1.11.0 to 1.12.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="9e3f88c06c"><code>9e3f88c</code></a>
Publish 1.12</li>
<li><a
href="187d8b8e84"><code>187d8b8</code></a>
Support Unicode 16.0.0 (<a
href="https://redirect.github.com/unicode-rs/unicode-segmentation/issues/140">#140</a>)</li>
<li><a
href="0f55f70b44"><code>0f55f70</code></a>
Fix unwrap panic in next_boundary() (<a
href="https://redirect.github.com/unicode-rs/unicode-segmentation/issues/137">#137</a>)</li>
<li><a
href="0fa7148d3b"><code>0fa7148</code></a>
Merge pull request <a
href="https://redirect.github.com/unicode-rs/unicode-segmentation/issues/138">#138</a>
from cardigan1008/issue-overflow</li>
<li><a
href="164f787b72"><code>164f787</code></a>
fmt</li>
<li><a
href="cbb87720d2"><code>cbb8772</code></a>
fix: arithmetic overflow</li>
<li><a
href="2081c29df7"><code>2081c29</code></a>
Merge pull request <a
href="https://redirect.github.com/unicode-rs/unicode-segmentation/issues/136">#136</a>
from Jules-Bertholet/std-tables</li>
<li><a
href="e96ec2eb6c"><code>e96ec2e</code></a>
Use stdlib alphabetic and numeric character tables</li>
<li><a
href="592ce00a3f"><code>592ce00</code></a>
Merge pull request <a
href="https://redirect.github.com/unicode-rs/unicode-segmentation/issues/134">#134</a>
from Jules-Bertholet/fix</li>
<li><a
href="dce3a345cc"><code>dce3a34</code></a>
Add comments to <code>handle_incb_consonant</code></li>
<li>Additional commits viewable in <a
href="https://github.com/unicode-rs/unicode-segmentation/compare/v1.11.0...v1.12.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=unicode-segmentation&package-manager=cargo&previous-version=1.11.0&new-version=1.12.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>
2024-09-22 15:16:11 +08:00
dependabot[bot]
299a218de7
Bump tango-bench from 0.5.0 to 0.6.0 (#13861)
Bumps [tango-bench](https://github.com/bazhenov/tango) from 0.5.0 to
0.6.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="425ddb93be"><code>425ddb9</code></a>
v0.6.0</li>
<li><a
href="0da1bf5f39"><code>0da1bf5</code></a>
Fixing incorrect path to gnuplot graph</li>
<li><a
href="6b084ea189"><code>6b084ea</code></a>
Limit visibility of internal type</li>
<li><a
href="4ea09e2216"><code>4ea09e2</code></a>
Solo support (<a
href="https://redirect.github.com/bazhenov/tango/issues/35">#35</a>)</li>
<li><a
href="abd888cbc0"><code>abd888c</code></a>
toolchain file added</li>
<li><a
href="2d722474ff"><code>2d72247</code></a>
Async poc (dev-branch) (<a
href="https://redirect.github.com/bazhenov/tango/issues/34">#34</a>)</li>
<li><a
href="5e236aec24"><code>5e236ae</code></a>
Simplify code</li>
<li><a
href="40569a9c98"><code>40569a9</code></a>
Documentation added</li>
<li><a
href="5908909fb2"><code>5908909</code></a>
README updated</li>
<li><a
href="6fb1ebd6f6"><code>6fb1ebd</code></a>
Gnuplot support (<a
href="https://redirect.github.com/bazhenov/tango/issues/33">#33</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/bazhenov/tango/compare/v0.5.0...v0.6.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=tango-bench&package-manager=cargo&previous-version=0.5.0&new-version=0.6.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>
2024-09-22 15:15:58 +08:00
Wind
1a081c09de
Bump version to 0.98.1 (#13896) 2024-09-22 12:41:44 +08:00
Devyn Cairns
6e1e824473
Bump version to 0.98.0 (#13865) 2024-09-18 00:48:46 -07:00
Jack Wright
af77bc60e2
Improved null handling when converting from nu -> dataframe. (#13855)
# Description
Fixes: #12726 and #13185

Previously converting columns that contained null caused polars to force
a dtype of object even when using a schema.

Now:
1. When using a schema, the type the schema defines for the column will
always be used.
2. When a schema is not used, the previous type is used when a value is
null.

# User-Facing Changes
- The type defined by the schema we be respected when passing in a null
value `[a]; [null] | polars into-df -s {a: str}` will create a df with
an str dtype column with one null value versus a column of type object.
- *BREAKING CHANGE* If you define a schema, all columns must be in the
schema.
2024-09-16 18:07:13 -05:00
Devyn Cairns
9ca0fb772d
Make IR the default evaluator (#13718)
# Description

Makes IR the default evaluator, in preparation to remove the non-IR
evaluator in a future release.

# User-Facing Changes

* Remove `NU_USE_IR` option
* Add `NU_DISABLE_IR` option
* IR is enabled unless `NU_DISABLE_IR` is set

# After Submitting
- [ ] release notes
2024-09-15 14:54:38 -07:00
Jack Wright
c535c24d03
catch unwrap on panics with polars collect (#13850)
# Description
This resurrects the work from #12866 and fixes #12732. 

Polars panics for a plethora or reasons. While handling panics is
generally frowned upon, in cases like with `polars collect` a panic
cause a lot of work to be lost. Often you might have multiple dataframes
in memory and you are trying one operation and lose all state.

While it possible the panic can leave things a strange state, it is
pretty unlikely as part of a polars pipeline. Most of the time polars
objects are not manipulating dataframes in memory mutability, but rather
creating a new dataframe the operations being applied. This is always
the case with a lazy pipeline. After the collect call, the original
dataframes are intact still and I haven't observed any side effects.
2024-09-15 07:21:02 -05:00
Justin Ma
c9cb62067c
Fix dockerfile and reset Nu config to default (#13851)
<!--
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

Fix dockerfile and reset Nu config to default, fetching config file from
the remote may cause compatible issues
2024-09-15 20:03:22 +08:00
Darren Schroeder
ebc7b80c23
allow tab to be retained with find (#13848)
# Description

This PR allows the tab character to be retained when using `find`.

### Before

![image](https://github.com/user-attachments/assets/92d78f55-58fb-42f4-be8f-82992292c900)

### After

![image](https://github.com/user-attachments/assets/fbd8e47f-9806-4e30-89a1-6c88b12a612c)


closes #13846

# 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.
-->
2024-09-14 08:51:00 -05:00
Justin Ma
aaaab8e070
Update Nu for release workflow and fix build warning of musl targets (#13840)
<!--
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

1. Update Nushell to v0.97.1 for release workflow
2. Fix musl targets cross compiling warning like: `warning: File system
loop found:
/home/runner/work/nightly/nightly/aarch64-linux-musl-cross/usr points to
an ancestor /home/runner/work/nightly/nightly/aarch64-linux-musl-cross/`

Tested in
https://github.com/nushell/nightly/actions/runs/10849647834/job/30109290106
2024-09-13 22:03:31 +08:00
Devyn Cairns
a59477205d
Fix try: Add set_last_error() to prepare_error_handler() for IR eval (#13838)
# Description

Fixes a bug with `set_last_error()` introduced by @IanManske not being
called during the jump to an error handler in IR eval. Without this,
`$env.LAST_EXIT_CODE` wasn't getting set in the `catch` block for an
external.

# Tests + Formatting

Added a `tests/eval` test to cover this in both IR and non-IR eval
2024-09-13 00:07:22 -07:00
nome
5101b5e306
Add --number flag to split column (#13831)
This allows parsing of data (e.g. key-value pairs) where the last column
may contain the delimiter.

- this PR should close #13742

# Description

Adds a `--number (-n)` flag to `split column`, analogous to `split row
--number`.

```
~> ['author: Salina Yoon' r#'title: Where's Ellie?: A Hide-and-Seek Book'#] | split column --number 2 ': ' key value
╭───┬────────┬──────────────────────────────────────╮
│ # │  key   │                value                 │
├───┼────────┼──────────────────────────────────────┤
│ 0 │ author │ Salina Yoon                          │
│ 1 │ title  │ Where's Ellie?: A Hide-and-Seek Book │
╰───┴────────┴──────────────────────────────────────╯
```

# User-Facing Changes
* `split column` gains a `--number` option

# Tests + Formatting
Tests included in strings::split::column::test::test_examples and
commands::split_column::to_column.

# After Submitting
Reference documentation is auto-generated from code. No other
documentation updates necessary.
2024-09-12 07:16:33 -05:00
Jack Wright
fb34a4fc6c
Make polars save return an empty pipeline (#13833)
# Description
In order to be more consistent with it's nu counterpart, `polars save`
now returns an empty pipeline instead of a message of the saved file.

# User-Facing Changes
- `polars save` no longer displays a save message, making it consistent
with `save` behavior.
2024-09-12 06:23:40 -05:00
Tooster
1bcceafd93
Improve #12008 UX, clear scrollback by default on clear (#13821)
<!--
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.
-->

Related to #11693. It looks like there is no reason for Nu shell's
`clear` to behave differently than other shells' `clear`. To improve the
UX and fulfill the user expectations, the default has been adjusted to
work the same as in other shells by clearing the scrollback buffer. For
edge cases where someone depends on the current behavior of keeping the
scrollback, a `-k` option has been added.

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

- Improve the UX of `clear` by changing the default behavior to the same
as other popular shells, i.e clear scrollback by default.
- Remove `-a --all` flag, make it the default behavior to clear the
scrollback
- Add `-k --keep-scrollback` flag for backward compat to keep the
scrollback buffer

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

This is a simple change flipping the flag and default behavior, no tests
should be needed.

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

- [ ] update the `clear` command docs

---------

Co-authored-by: Douglas <32344964+NotTheDr01ds@users.noreply.github.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2024-09-11 15:33:20 -05:00
Wind
217eb4ed70
fix path exists on a non-directory file (#13763)
# Description
Fixes:  #13460

The issue is caused by `try_exists` method on path, it will return
`Err(NotADirectory)` if user tried to check for a path under a regular
file.
To fix it, I think it's ok to use `exists` rather than `try_exists`,
although
[Path::exists()](https://doc.rust-lang.org/std/path/struct.Path.html#method.exists)
only checks whether or not a path was both found and readable. I think
it's ok, and we can add this information under `extra_description`.

# User-Facing Changes
The following code will no longer raise error:
```
touch a; 'a/b' | path exists
```

# Tests + Formatting
Added 1 test.
2024-09-11 12:45:39 -05:00
Wind
78af66f2ce
Config: change ctrl-k to cuttolineend event (#13801)
# Description
According to emacs doc, I think `ctrl-k` should map to `cuttolineend`.

# User-Facing Changes
`ctrl-k` will no longer cut to the end of buffer
2024-09-11 12:45:12 -05:00
Bahex
f63cecc316
add metadata access command (#13785)
# Description
Add `metadata access`, which allows accessing/inspecting the metadata of
a stream in a closure.
```nu
ls | metadata access {|meta|
    ...
}
```

- The metadata is provided as an argument to the closure, identical to
the record obtained with `metadata` command.

- `metadata access` passes its input stream into the closure as it is.

- Within the closure, both the metadata and the stream are available.
The closure may modify, collect or pass the stream as it is.

# Motivation
- Without this command, nu code can't act on metadata without losing the
stream, use cases requiring both the stream and metadata must be
implemented either as a built-in or a plugin.

- This command allows users to enhance presentation of data, similar to
`table` coloring the output of `ls`.
2024-09-11 12:44:06 -05:00
Jack Wright
8d60c0d35d
Migrating polars commands away from macros, removed custom DataFrame comparison. (#13829)
# Description
This PR:
- Removes the lazy_command, expr_command macros and migrates the
commands that were utilizing them.
- Removes the custom logic in DataFrameValues::is_equals to use the
polars DataFrame version of PartialEq
- Adds examples to commands that previously did not have examples or had
inadequate ones.

NOTE: A lot of examples now have a `polars sort` at the end. This is
needed due to the comparison in the result. The new polars version of
equals cares about the ordering. I removed the custom equals logic as it
causes comparisons to lock up when comparing dataframes that contain a
row that contains a list. I discovered this issue when adding examples
to `polars implode`
2024-09-11 10:33:05 -07:00
Maxim Zhiburt
0c139c7411
Fix padding issue with header_on_border (#13808)
close #13803 

For your @amtoine  example we get

```
#┬c-a┬c-b┬c-c┬c-d─┬─c-e─
0│  1│ 12│123│1234│12345
─┴───┴───┴───┴────┴─────
```
2024-09-11 06:12:53 -05:00
dependabot[bot]
c4bac90b35
Bump crate-ci/typos from 1.24.4 to 1.24.5 (#13826)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.24.4 to
1.24.5.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/crate-ci/typos/releases">crate-ci/typos's
releases</a>.</em></p>
<blockquote>
<h2>v1.24.5</h2>
<h2>[1.24.5] - 2024-09-04</h2>
<h3>Features</h3>
<ul>
<li><em>(action)</em> Support windows</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/crate-ci/typos/blob/master/CHANGELOG.md">crate-ci/typos's
changelog</a>.</em></p>
<blockquote>
<h2>[1.24.5] - 2024-09-04</h2>
<h3>Features</h3>
<ul>
<li><em>(action)</em> Support windows</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="945d407a5f"><code>945d407</code></a>
chore: Release</li>
<li><a
href="e972e95d22"><code>e972e95</code></a>
docs: Update changelog</li>
<li><a
href="fcfade456a"><code>fcfade4</code></a>
Merge pull request <a
href="https://redirect.github.com/crate-ci/typos/issues/1095">#1095</a>
from zyf722/actions-windows</li>
<li><a
href="264f549c13"><code>264f549</code></a>
feat(action): Add Windows support to actions</li>
<li>See full diff in <a
href="https://github.com/crate-ci/typos/compare/v1.24.4...v1.24.5">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=crate-ci/typos&package-manager=github_actions&previous-version=1.24.4&new-version=1.24.5)](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>
2024-09-11 14:35:46 +08:00
dependabot[bot]
2ab8751ff9
Bump hustcer/setup-nu from 3.12 to 3.13 (#13827)
Bumps [hustcer/setup-nu](https://github.com/hustcer/setup-nu) from 3.12
to 3.13.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/hustcer/setup-nu/releases">hustcer/setup-nu's
releases</a>.</em></p>
<blockquote>
<h2>v3.13</h2>
<h2>[3.13] - 2024-09-07</h2>
<h3>Features</h3>
<ul>
<li>Add <code>aarch64_linux</code> and <code>aarch64_windows</code>
runners support</li>
</ul>
<h3>Deps</h3>
<ul>
<li>Upgrade
<code>@​octokit/rest</code>,globby,<code>@​biomejs/biome</code>,lefthook,
etc.</li>
<li>Upgrade semver,lefthook,<code>@​octokit/rest</code> and
@typescript-eslint/*</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/hustcer/setup-nu/compare/v3.12...v3.13">https://github.com/hustcer/setup-nu/compare/v3.12...v3.13</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/hustcer/setup-nu/blob/main/CHANGELOG.md">hustcer/setup-nu's
changelog</a>.</em></p>
<blockquote>
<h2>[3.13] - 2024-09-07</h2>
<h3>Features</h3>
<ul>
<li>Add <code>aarch64_linux</code> and <code>aarch64_windows</code>
runners support</li>
</ul>
<h3>Deps</h3>
<ul>
<li>Upgrade
<code>@​octokit/rest</code>,globby,<code>@​biomejs/biome</code>,lefthook,
etc.</li>
<li>Upgrade semver,lefthook,<code>@​octokit/rest</code> and
@typescript-eslint/*</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="5dfe3b1a9e"><code>5dfe3b1</code></a>
Bump to v3.13</li>
<li><a
href="7f30320d51"><code>7f30320</code></a>
deps: Upgrade <code>@​octokit/rest</code>, lefthook and
@typescript-eslint/*</li>
<li><a
href="aed3675fdb"><code>aed3675</code></a>
deps: Upgrade semver,lefthook,<code>@​octokit/rest</code> and
@typescript-eslint/*</li>
<li><a
href="cb4476b15e"><code>cb4476b</code></a>
deps: Upgrade
<code>@​octokit/rest</code>,globby,<code>@​biomejs/biome</code>,lefthook
and <a
href="https://github.com/typescript-es"><code>@​typescript-es</code></a>...</li>
<li><a
href="25c9361cd1"><code>25c9361</code></a>
feat: Add aarch64_linux and aarch64_windows runners support</li>
<li>See full diff in <a
href="https://github.com/hustcer/setup-nu/compare/v3.12...v3.13">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=hustcer/setup-nu&package-manager=github_actions&previous-version=3.12&new-version=3.13)](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>
2024-09-11 14:35:38 +08:00
dependabot[bot]
d192d854d6
Bump shadow-rs from 0.33.0 to 0.34.0 (#13825)
Bumps [shadow-rs](https://github.com/baoyachi/shadow-rs) from 0.33.0 to
0.34.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/baoyachi/shadow-rs/releases">shadow-rs's
releases</a>.</em></p>
<blockquote>
<h2>v0.34.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Make using the CARGO_METADATA object simpler by <a
href="https://github.com/baoyachi"><code>@​baoyachi</code></a> in <a
href="https://redirect.github.com/baoyachi/shadow-rs/pull/181">baoyachi/shadow-rs#181</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/baoyachi/shadow-rs/compare/v0.33.0...v0.34.0">https://github.com/baoyachi/shadow-rs/compare/v0.33.0...v0.34.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="ccb09f154b"><code>ccb09f1</code></a>
Merge pull request <a
href="https://redirect.github.com/baoyachi/shadow-rs/issues/181">#181</a>
from baoyachi/issue/179</li>
<li><a
href="65c56630da"><code>65c5663</code></a>
fix cargo clippy check</li>
<li><a
href="998d000023"><code>998d000</code></a>
Make using the CARGO_METADATA object simpler</li>
<li>See full diff in <a
href="https://github.com/baoyachi/shadow-rs/compare/v0.33.0...v0.34.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=shadow-rs&package-manager=cargo&previous-version=0.33.0&new-version=0.34.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>
2024-09-11 14:35:27 +08:00
Devyn Cairns
6b5906613c
Fix remaining mismatch for env handling in IR (#13796)
# Description

This fixes a couple of remaining differences between the IR evaluator's
handling of env vars and the AST evaluator's handling of env vars.

Blocker for #13718 (this is why those tests failed)

# User-Facing Changes

1. Handles checking overlays for hidden env vars properly, when getting
an env var from IR instruction
2. Updates config properly when doing `redirect_env()` (these probably
shouldn't be separate functions anyway, though, they're basically the
same. I did this because I intended to remove one, but now it's just
like that)

# Tests + Formatting

The `nu_repl` testbin now handles `NU_USE_IR` properly, so these tests
now work as expected.

# After Submitting

- [ ] check in on #13718 again
2024-09-10 11:03:06 +08:00
Ian Manske
493850b1bf
Fix IR for try (#13811)
# Description
Fixes a bug in the IR for `try` to match that of the regular evaluator
(continuing from #13515):
```nushell
# without IR:
try { ^false } catch { 'caught' } # == 'caught'

# with IR:
try { ^false } catch { 'caught' } # error, non-zero exit code
```

In this PR, both now evaluate to `caught`. For the implementation, I had
to add another instruction, and feel free to suggest better
alternatives. In the future, it might be possible to get rid of this
extra instruction.

# User-Facing Changes
Bug fix, `try { ^false } catch { 'caught' }` now works in IR.
2024-09-09 19:44:04 -07:00
Anton Sagel
6600b3edfb
Expand multiple dots in path in completions (#13725)
# Description
This is my first PR, and I'm looking for feedback to help me improve! 

This PR fixes #13380 by expanding the path prior to parsing it.
Also I've removed some unused code in
[completion_common.rs](84e92bb02c/crates/nu-cli/src/completions/completion_common.rs
)
# User-Facing Changes

Auto-completion for "cd .../" now works by expanding to "cd ../../". 

# Tests + Formatting

Formatted and added 2 tests for triple dots in the middle of a path and
at the end.
Also added a test for the expand_ndots() function.
2024-09-09 14:39:18 -04:00
Justin Ma
aff974552a
Add aarch64-unknown-linux-musl and armv7-unknown-linux-musleabihf targets to release workflow (#13800)
# Description

Add aarch64-unknown-linux-musl and armv7-unknown-linux-musleabihf
targets to release workflow. This PR and
https://github.com/nushell/nushell/pull/13775 will close:
https://github.com/nushell/nushell/issues/10444

It works well here:
https://github.com/nushell/nightly/releases/tag/nightly-2d360fd
2024-09-09 09:47:59 +08:00
Darren Schroeder
2afc6a974e
bump rust version to 1.79.0 (#13809)
# Description

This PR bumps our rust version from 1.78 to 1.79.0 due to the 1.81.0
release.

# 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.
-->
2024-09-08 16:15:54 -05:00
Jack Wright
1e64f59220
Added documentation explanation explaining how to select all columns with polars col (#13806)
# Description
Previously there were no examples or explanations that you can use '*'
to select all columns. Updated description and added a new example.
2024-09-08 17:12:03 +00:00
xonas
3e074bc447
Refining error handling in http post (#13805)
Related to #13701

# Description
Refining some of the error handling related to http post command
2024-09-07 23:57:34 +02:00
Ian Manske
3d008e2c4e
Error on non-zero exit statuses (#13515)
# Description
This PR makes it so that non-zero exit codes and termination by signal
are treated as a normal `ShellError`. Currently, these are silent
errors. That is, if an external command fails, then it's code block is
aborted, but the parent block can sometimes continue execution. E.g.,
see #8569 and this example:
```nushell
[1 2] | each { ^false }
```

Before this would give:
```
╭───┬──╮
│ 0 │  │
│ 1 │  │
╰───┴──╯
```

Now, this shows an error:
```
Error: nu:🐚:eval_block_with_input

  × Eval block failed with pipeline input
   ╭─[entry #1:1:2]
 1 │ [1 2] | each { ^false }
   ·  ┬
   ·  ╰── source value
   ╰────

Error: nu:🐚:non_zero_exit_code

  × External command had a non-zero exit code
   ╭─[entry #1:1:17]
 1 │ [1 2] | each { ^false }
   ·                 ──┬──
   ·                   ╰── exited with code 1
   ╰────
```

This PR fixes #12874, fixes #5960, fixes #10856, and fixes #5347. This
PR also partially addresses #10633 and #10624 (only the last command of
a pipeline is currently checked). It looks like #8569 is already fixed,
but this PR will make sure it is definitely fixed (fixes #8569).

# User-Facing Changes
- Non-zero exit codes and termination by signal now cause an error to be
thrown.
- The error record value passed to a `catch` block may now have an
`exit_code` column containing the integer exit code if the error was due
to an external command.
- Adds new config values, `display_errors.exit_code` and
`display_errors.termination_signal`, which determine whether an error
message should be printed in the respective error cases. For
non-interactive sessions, these are set to `true`, and for interactive
sessions `display_errors.exit_code` is false (via the default config).

# Tests
Added a few tests.

# After Submitting
- Update docs and book.
- Future work:
- Error if other external commands besides the last in a pipeline exit
with a non-zero exit code. Then, deprecate `do -c` since this will be
the default behavior everywhere.
- Add a better mechanism for exit codes and deprecate
`$env.LAST_EXIT_CODE` (it's buggy).
2024-09-07 06:44:26 +00:00
Jack Wright
6c1c7f9509
Added expression support for polars cumulative (#13799)
# Description
Provides the ability to use `polars cumulative` as an expression:

<img width="1266" alt="Screenshot 2024-09-06 at 17 47 15"
src="https://github.com/user-attachments/assets/73c11f79-598c-4efa-bfcd-755e536ead66">

# User-Facing Changes
- `polars cumulative` can now be used as an expression.
2024-09-06 22:03:51 -05:00
Jack Wright
f531cc2058
Polars command reorg (#13798)
# Description
House keeping. Restructures polars modules as discussed in:
https://docs.google.com/spreadsheets/d/1gyA58i_yTXKCJ5DbO_RxBNAlK6S7C1M22ppKwVLZltc/edit?usp=sharing
2024-09-06 13:46:37 -07:00
Darren Schroeder
edd69aa283
update the latest reedline (#13797)
# Description

I swear, I only did `cargo update -p reedline`. However, I feel down the
dependency rabbit hole. We need to get nushell on crossterm 28.1 and
ratatui on 28.1 but we can't because tabled uses papergrid which uses an
older version of unicode-width that can't be upgraded apparently. Ugh.
I've opened an issue at the tabled repo about this.

# 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.
-->
2024-09-06 09:57:45 -05:00
Wind
3d20c53904
make a user friendly message when use_grid_icons is used in config (#13795)
# Description
After merging #13788, I get an error message which says that
`use_grid_icons` is invalid.

I think it's good to report the specific error, and guide user to delete
it.
2024-09-06 06:39:52 -05:00
Jack Wright
2d360fda7f
String values should pass their content-type correctly on http requests with a body (e.g. http post) (#13731)
# Description
The content-type was not being handled appropriately when sending
requests with a string value.

# User-Facing Changes
- Passing a string value through a pipeline with a content-type set as
metadata is handled correctly
- Passing a string value as a parameter with a content-type set as a
flag is handled correctly.
2024-09-05 16:29:50 -07:00
Darren Schroeder
d0c2adabf7
remove config use_grid_icons, move to parameter of grid command (#13788)
# Description

After looking at #13751 I noticed that the config setting
`use_grid_icons` seems out of place. So, I removed it from the config
and made it a parameter to the `grid` command.
2024-09-06 07:25:43 +08:00
Darren Schroeder
870eb2530c
fixed issue with find not working with symbols that should be escaped (#13792)
# Description

Thanks to @weirdan's suggestion, this now works.

![image](https://github.com/user-attachments/assets/34522c7b-b012-4f73-883d-9913142e85b9)

Closes #13789
2024-09-06 07:22:03 +08:00
Darren Schroeder
b2cab3274b
fix --ide-ast when there are errors (#13737)
# Description

This PR fixes #13732. However, I don't think it's a proper fix.
1. It doesn't really show what the problem is.
2. It kind of side-steps the error entirely.

I do think the change in span.rs may be valid because I don't think
span.end should ever be 0. In the example in 13732 the span end was
always 0 and so that made contains_span() return true, which seems like
a false positive.

The `checked_sub()` in ide.rs kind of just stops it from failing
outloud.

I'll leave it to smarter folks than me to land this if they think it's
worthy.
2024-09-06 07:17:40 +08:00
Stefan Holderbach
92091599ff
Fixup serde feature selection in nu-protocol (#13793)
Discovered by @cptpiepmatz that #13749 broke the standalone check for
`nu-protocol`

Explicit use of the feature as workspace root also disables all features
for `serde`. Alternatively we could reconsider this there.
2024-09-06 00:57:36 +02:00
Jack Wright
4d2d553cca
Use String::contains instead of exact match when matching content types for http requests. (#13791)
# Description
The existing code uses exact matches on content type. This can caused
things like "application/json; charset=utf-8" that contain a charset not
using send_json method.

NOTE: The charset portion in the above example would still be ignored as
we rely on serde and the client library to control the encoding, it is
still better to catch the json case.

---------

Co-authored-by: Ian Manske <ian.manske@pm.me>
2024-09-05 13:08:19 -05:00