Commit Graph

4828 Commits

Author SHA1 Message Date
Astrick
a86f34d0ad
Add zip-into-record to std iter (#9395)
# Description
Adds a new iter feature `zip-into-record` (#9380)

# User-Facing Changes
User can use `[1 2] | iter zip-into-record [3 4]` to create a table `[[1
2]; [3 4]]`

# Tests + Formatting

I noticed trailing spaces in std library that may wish to be cleaned in
the future.

Co-authored-by: amtoine <stevan.antoine@gmail.com>
2023-06-10 20:15:30 +02:00
Antoine Stevan
9fcc49e556
REFACTOR: simplify the declaration of extra commands (#9398)
cc/ @stormasm 

# Description
i was about to start the cratification of the 0% commands and thought i
could refactor and simplify a bit the declaration of the `bits`
commands, having hopefully a simpler structure to work with the other
commands 😌

this PR:
- gives real names to all the `bits` commands, instead of `SubCommand`
- make them publicly available inside the `nu-cmd-extra` crate to
declare them through `add_extra_decls`
- move the declaration code to the top-level `mod.nu` of `nu-cmd-extra`
so that all commands can be declared there as in `default_context` in
`nu-command`

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-06-10 10:33:33 -07:00
Filip Andersson
1433f4a520
Changes HashMap to use aHash instead, giving a performance boost. (#9391)
# Description

see https://github.com/nushell/nushell/issues/9390
using `ahash` instead of the default hasher. this will not affect
compile time as we where already building `ahash`.


# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-10 11:41:58 -05:00
WindSoilder
6e638ab381
disable bracketed paste during evaluation (#9399)
# Description
Fixes: #9218

When user execute some commands involve user input, currently if we
enable `bracketed_paste`, it will results strange behavior (Pasting `0~`
and `1~` around texts, e.g: `aaa` -> `0~aaa1~`) And this is why `gpg`
with paste failed.

Sorry that it's hard to make relative testing...

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-10 09:42:13 -05:00
WindSoilder
5afd74f0b9
don't allow save command to save both stdout and stderr to the same file (#9368)
# Description
It's not a good idea to save `stdout` and `stderr` to the same file from
`save` command directly.

Because it saves `stdout` and `stderr` in different thread, which leads
to in-consistent output. As replace, we can use `o+e` redirection to fix
the issue

# User-Facing Changes
```
❯ do -i { "aa" } | save foo.txt -e foo.txt
Error:   × input and stderr input to same file
   ╭─[entry #3:1:1]
 1 │ do -i { "aa" } | save foo.txt -e foo.txt
   ·                                  ───┬───
   ·                                     ╰── can't save both input and stderr input to the same file
   ╰────
  help: you should use `o+e> file` instead
```

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-10 10:09:19 +02:00
WindSoilder
191cd2c970
save command: Don't use BufWriter to write external strem to a file (#9377)
# Description
Fixes: #9293

The problem is caused by `save` makes a `BufferWriter` for output file,
when external commands redirect it's output to a file, the content is
bufferred first...

To fix the issue, I'd like to introduce a `--no-buf` flag for `save`
command, and it's only used in redirection scenario.

Sorry it's hard to test against it in test, because it requires external
command to sleep or pause...

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-06-10 10:07:26 +02:00
WindSoilder
1edd3e7c3b
add http options command (#9365)
# Description
closes: #9344

Different to other http commands, `http options` command always returns
header, according to
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS),
the response information is included in header.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-09 08:00:40 -05:00
Stefan Holderbach
a5dd93d154
Apply nightly clippy fixes (#9381)
# Description
New lints coming from `cargo +nightly clippy`

Manually checked for problems.


# User-Facing Changes
None

# Tests + Formatting
(-)
2023-06-08 18:49:58 +02:00
Gurpreet Singh
15a15c123e
Add a check for empty params for url join (#9356)
# 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.
-->

Fix for #9347 

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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
> ```
-->
- [x] Add unit tests
- [x] Run all cargo tests + fmt commands

# 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.
-->
2023-06-07 19:08:21 +02:00
Stefan Holderbach
20b697f722
Fix internal module reexports (#9378)
# Description
`cargo +stable check` was complaining about ambiguous wildcard
reexports. Fixed by making the reexport of modules not pub as only the
explicitly named symbols are actually needed in the current state.


# User-Facing Changes
None
2023-06-07 16:36:34 +02:00
nibon7
a1a3ef4608
Fix typos (#9372)
# Description
Fix typo
2023-06-07 15:07:14 +02:00
Stefan Holderbach
d15859dd86
Bump to 0.81.1 as development version (#9379)
# Description
Primarily used as a marker on issues and if necessary as a patch release
version.
2023-06-07 15:06:42 +02:00
JT
63cb01e83b
bump to 0.81 (#9374)
# 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.
-->

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-07 10:08:11 +12:00
Stefan Holderbach
ef38805ef9
Pin reedline to 0.20.0 release (#9370)
# Description
See release notes

https://github.com/nushell/reedline/releases/tag/v0.20.0
2023-06-06 13:16:18 +02:00
Jakub Žádník
82e6873702
Fix config creation during printing (#9353) 2023-06-04 22:04:28 +03:00
Kamil
df15fc24fe
Logger constants refactored, format argument added, better formatting of failed (non) equality assertions (#9315)
# Description
I have (hopefully) simplified the `log.nu` internal structure and added
customizable log format for all `log` commands

# User-Facing Changes
- [x] Replaced constants with env records for: 
    - ansi (newly added)
    - log level
    - prefix
    - short prefix
- [x] Added `format` argument to all log commands
- [x] Assertions for (not) equality (equal, not equal, greater,
lesser...) now put left and right values inside `'` quotes, so the
assertions for strings are more meaningful
- [x] Documented the %-formatting of log messages

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: amtoine <stevan.antoine@gmail.com>
2023-06-04 10:43:40 +02:00
Darren Schroeder
7ca62b7b35
fix is-admin example (#9350)
# Description

closes #9348 

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-03 15:11:14 -05:00
Alex Saveau
8f4c182a0c
Explain how to do time based bash watch (#9345) 2023-06-03 11:15:47 -05:00
Darren Schroeder
acd2fe8c51
bump rust toolchain to 1.68.2 (#9346)
# Description

In keeping with our tradition of staying 2 versions behind the latest
rust compiler version, this PR bump the toolchain to 1.68.2.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-02 17:30:15 -05:00
Darren Schroeder
5c57d6a74d
add the ability to have a list of glob excludes (#9343)
# Description

This change allows you to have a list of exclude globs such as:
```
glob **/* --not [**/target/** **/.git/**]
```

TODO: Allow the input glob to be multiples too with
`wax::any(patterns)?`

The breaking change part is that the excludes have to be supplied as a
list, between [ and ].

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-02 12:37:17 -05:00
ShinyZero0
2ac63910f6
stdlib: add termux clipboard suport for clip (#9334)
# Description

Added `termux-clipboard-set` to `std clip`
2023-06-01 16:26:22 -05:00
solodov
55689ddb50
use "search_result" style to colorize matching strings (fixes #9275) (#9326)
This change introduces new `search_result` style supported in the color
config. The change also removes obsolete check for `config.ls_colors`
for computing the style. `config.ls_colors` has been removed last year,
so this removes the reference to the obsolete flag, along with a cleanup
that removes all the code that used to rely on ls_colors for
highlighting search results.


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

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-01 15:51:18 -05:00
Darren Schroeder
3aab69110e
Some tests added with github copilot preview (#9332)
# Description

This PR adds some tests that were generated in GitHub Copilot Chat
Preview. I was just playing around and figured that more tests couldn't
hurt.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-06-01 15:24:36 -05:00
Michael Angerman
b9e65e35b8
include the nu-cmd-extra crate in the version command features (#9333)
We needed to include the nu-cmd-extra crate in the version command's
features...

In the style of this PR which fixed the dataframe feature upon adding
the nu-cmd-dataframe crate...

https://github.com/nushell/nushell/pull/9262
2023-06-01 13:10:39 -07:00
Michael Angerman
356e05177c
nu-cmd-extra crate infrastructure in place with the Bits command as the model for adding other commands (#9327)
I wanted to get the infrastructure in place for starters for our
*nu-cmd-extra* crate...

The plan is to put inside here the following commands...

* bits
* bytes
* math

I thought it would be easier to do one at a time as well as get the
nu-cmd-extra crate out there on crates.io
for this upcoming release...

Once this lands the infrastructure will be in place to move over the
other noted commands for now...
And then add other stuff we do NOT want to be in 1.0.
2023-06-01 10:46:16 -07:00
simdimdim
2f731fa1ae
Adding more math constants (and a small correction to the description of an existing one) (#9181)
Adding more float constants for when
https://github.com/rust-lang/rust/issues/103883 is accepted and merged.
And fixing a small conflation in the description of the Euler number.
Please take a look and let me know if I've missed or screwed up
anything.
2023-05-31 20:28:08 -05:00
Carter Reeb
e6be167797
fix padding when running input list on tables (#9316)
# Description
Improves the output when running `input list` on tabular data by
aligning each column.

# User-Facing Changes
## Before

![before](https://github.com/nushell/nushell/assets/39879966/b6a93568-f37c-4bd3-93eb-efa41cac1baf)
## After

![after](https://github.com/nushell/nushell/assets/39879966/35d74bc7-6f72-42c4-89e7-f54692ccd3ff)

<!-- 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-31 18:31:46 +02:00
WindSoilder
bfe7133e7c
make insert, update, upsert support lazy records (#9323)
# Description
Fixes: #9165
It's because `sys` returns a lazy record, and `insert`, `update`,
`upsert` can't operate on lazy record yet.

# User-Facing 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-31 06:27:55 -05:00
Maxim Zhiburt
5f8d8b4a4b
nu-explore/ Fix recursive table issue; (#9321)
close #9318

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-05-30 09:59:56 -05:00
WMR
b67b6f7fc5
Add a datepart expression for dfr to be used with dfr with-column (#9285)
# Description

Today the only way to extract date parts from a dfr series is the dfr
get-* set of commands. These create a new dataframe with just the
datepart in it, which is almost entirely useless. As far as I can tell
there's no way to append it as a series in the original dataframe. In
discussion with fdncred on Discord we decided the best route was to add
an expression for modifying columns created in dfr with-column. These
are the way you manipulate series within a data frame.

I'd like feedback on this approach - I think it's a fair way to handle
things. An example to test it would be:

```[[ record_time]; [ (date now)]]  | dfr into-df | dfr with-column [ ((dfr col record_time) | dfr datepart nanosecond | dfr as "ns" ), (dfr col record_time | dfr datepart second | dfr as "s"), (dfr col record_time | dfr datepart minute | dfr as "m"), (dfr col record_time | dfr datepart hour | dfr as "h") ]```

I'm also proposing we deprecate the dfr get-* commands.  I've not been able to figure out any meaningful way they could ever be useful, and this approach makes more sense by attaching the extracted date part to the row in the original dataframe as a new column.

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

# User-Facing Changes

add in dfr datepart as an expression
<!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. -->

# Tests + Formatting
Need to add some better assertive tests.  I'm also not sure how to properly write the test_dataframe at the bottom, but will revisit as part of this PR.  Wanted to get feedback early.

<!--
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 -A clippy::needless_collect -A clippy::result_large_err` to check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: Robert Waugh <robert@waugh.io>
2023-05-30 09:41:18 -05:00
nibon7
560c2e63ac
restore cursor shape when exits (#9314)
# Description
This PR restores cursor shape when nushell exists.

Fixes #9243 

Related
[nushell/reedline#574](https://github.com/nushell/reedline/pull/574)

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

* windows


https://github.com/nushell/nushell/assets/15247421/ede8d1c0-ecd1-40b0-87b0-6393c1a7160f


* linux


https://github.com/nushell/nushell/assets/15247421/b428f17e-05cb-45ad-aa5f-3a9753fd9176

* macos


https://github.com/nushell/nushell/assets/15247421/5170dabd-8b9f-4bad-a7a2-bdabfca45cca

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-30 09:38:45 -05:00
Maxim Zhiburt
7f758d3e51
Merge stack before printing (#9304)
Could you @fdncred try it?

close?: #9264

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-29 19:03:00 -05:00
mike
cc04b9a916
fix conflict between filesize and hexadecimal numbers (#9309)
closes #9278 

# Description

removes ambiguity between the `b` the filesize `bytes` unit and `b` the
hex digit
2023-05-28 12:56:58 +02:00
Antoine Stevan
3005fe10e5
REFACTOR: move run-tests and fix the std assert namespace (#9303)
related to the namespace bullet point in
- https://github.com/nushell/nushell/issues/8450

# Description
this was the last module of the standard library with a broken
namespace, this PR takes care of this.

- `run-tests` has been moved to `std/mod.nu`
- `std/testing.nu` has been moved to `std/assert.nu`
- the namespace has been fixed
- `assert` is now called `main` and used in all the other `std assert`
commands
- for `std assert length` and `std assert str contains`, in order not to
shadow the built-in `length` and `str contains` commands, i've used
`alias "core ..." = ...` to (1) define `foo` in `assert.nu` and (2)
still use the builtin `foo` with `core foo` (replace `foo` by `length`
or `str contains`)
  - tests have been fixed accordingly

# User-Facing Changes
one can not use
```
use std "assert equal"
```
anymore because `assert ...` is not exported from `std`.
`std assert` is now a *real* module.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```

# Notes for reviewers
to test this, i think the easiest is to
- run `toolkit test stdlib` and see all the tests pass
- run `cargo run -- -n` and try `use std assert` => are all the commands
available in scope?
2023-05-27 07:45:04 -05:00
Michel Alexandre Salim
34b3a49cae
[nu-explore] fix Cargo description (#9297)
# Description
The old description ("Nushell table printing") is identical to that of
`nu-table`. Per `explore --help` it is probably more accurate to say
"Nushell table pager".

# User-Facing Changes
N/A

# Tests + Formatting
```
❯ cargo metadata --no-deps | from json | get packages | get 14 | get description
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
Nushell table pager
```

# After Submitting
N/A - change will go out when `0.82.0` is released

Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
2023-05-27 10:18:39 +02:00
Jack Wright
8144926dc7
Adding JSON lines file support to dataframes (#9291)
# Description
Provides the ability to read and write [JSON
lines](https://jsonlines.org/) files. This is accomplished by exposing
the support already in Polars.

## Opening a JSON lines file 
<img width="1668" alt="Screenshot 2023-05-25 at 5 25 30 PM"
src="https://github.com/nushell/nushell/assets/56345/3b213c3d-eea1-440a-8425-4ce4b39ab7d1">

## Saving a dataframe to a JSON lines file
<img width="848" alt="Screenshot 2023-05-25 at 5 15 57 PM"
src="https://github.com/nushell/nushell/assets/56345/56089990-e14b-4f01-b676-5abab9333d7e">
2023-05-26 16:32:37 -05:00
Darren Schroeder
5f92fd20e9
update most dependencies except where deeper code changes are needed (#9296)
# Description

This PR updates most dependencies and tries to get in sync with
reedline.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-26 10:32:48 -05:00
Antoine Stevan
6481bf272c
REFACTOR: build help pages instead of printing them (#9253)
# Description
in order to write tests for the `std help` commands, as we currently
have in the Rust source base, we need to be able to manipulate the
output of the `std help` commands.

however, until now they've all been directly printing the help pages as
they go...

this PR tries to build the help pages and return them at the end instead
of printing them on the fly 👍

> **Note**
> this is quite a rewrite of the `help.nu` module 🤔 
> i think it might be best to either
> - look at the commits in order
> - test the changes by testing the commands in the REPL and comparing
them to their previous `std help` versions

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-26 11:22:51 +02:00
Mel Massadian
9e667cc879
feat: (stdlib) add os record support to path add (#9238)
# 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.
-->
Add "os record" support.


# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
This don't change how path add works but just adds support for "os
records" aka records whose key are at least one of:
- linux
- macos
- windows

Check the
[test](a917f1a924/crates/nu-std/tests/test_std.nu (L31-L32))
if that's not clear enough

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: amtoine <stevan.antoine@gmail.com>
2023-05-26 09:24:53 +02:00
Antoine Stevan
3e55addbdd
refactor the lib.rs of nu-std after the new virtual files PR (#9289) 2023-05-25 22:43:07 +03:00
Access
e5ff72120a
check if is homedir first when rm (#9117)
I don't want to rm my home again.. sadly..


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

check if there is unique argument

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

user will not easily rm their home

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-25 09:45:50 -05:00
JT
43108de547
move over to reedline git version (#9283)
# Description
Moves us over to dogfooding the git version of reedline ahead of the
next release.

# User-Facing Changes

With luck, you should see fewer bugs :D

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-25 11:53:57 +12:00
JT
fa113172da
Fix clippy warnings (upcoming) (#9282)
# Description

Fixes the clippy warnings we're about to get hit with next time we
upgrade Rust.

The big one was shrinking ShellError and related under 128 bytes.

# User-Facing Changes

Shouldn't notice much difference. In theory, we could see a tiny perf
improvement, but I didn't notice one.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-25 10:58:18 +12:00
JT
7ead89844a
Cut down on unnecessary parsing for SyntaxShape::Any (#9280)
# Description

This removes some unnecessary SyntaxShapes when parsing a
SyntaxShape::Any. Recent updates to the parser look for `{` and then
handle the logic for that separately.

# User-Facing Changes

This may have a slight parser speedup.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-25 07:53:57 +12:00
Jakub Žádník
74724dee80
Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
Darren Schroeder
db4b26c1ac
some minor color fixups (#9270)
# Description

This PR cleans a couple things up. Nothing major, just a few things that
caught my eye looking for something else.
1. less macros
2. hidden and italic styles weren't fully available
3. lookup_color function didn't lookup all the colors available

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-23 09:33:03 -05:00
Bob Hyman
8e7405bf49
std dirs simply stays in sync with CD changes to PWD (#9267)
# 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.
-->
Fixes https://github.com/nushell/nushell/issues/9229.
Supersedes #9234

The reported problem was that `shells` list of active shells (a.k.a `std
dirs show` would show an inaccurate active
working directory if user changed it via `cd` command.

The fix here is for the `std dirs` module to let `$env.PWD` mask the
active slot of `$env.DIRS_LIST`. The user is free to invoke CD (or write
to `$env.PWD`) and `std dirs show` will display that as the active
working directory.

When user changes the active slot (via `n`, `p`, `add` or `drop`) `std
dirs` remembers the then current PWD in the about-to-be-vacated active
slot in `$env.DIRS_LIST`, so it is there if you come back to that slot.

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

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> [x] 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.
-->
2023-05-23 06:24:39 -05:00
Mel Massadian
77aee7e543
docs: 📝 "http get", add an example with more than one header (#9240)
# 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.
-->

I was trying `-H [key-A val-A] -H [key-B val-B]` but thanks to @Dorumin
I discovered how it should be used.
This PR just adds an extra example to the help with multiple headers.
Feel free to edit it either to merge both header examples into one or
rename the key value used, but I think it would be nice to have a sample
as the multiple -H variant doesn't error out it wasn't obvious to me.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
One more help example in `help http get`

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-22 13:55:19 -05:00
Tilen Gimpelj
60041879f3
throw an error instead of a panic if no input is provided to inspect (#9259)
# Description

This is a small PR to fix Nu crashing when calling `inspect` with no
data piped in(#9255).


# User-Facing Changes

none.
2023-05-22 13:54:04 -05:00
pwygab
a6e455efc3
upserting data of a cellpath that doesn't exist into a record creates the cellpath (#9257)
# Description
Fixes #9254.

# User-Facing Changes
upserting data of a cellpath that doesn't exist into a record now
creates the cellpath.

# Tests + Formatting

```
~/CodingProjects/nushell> mut a = {}                                                                       
~/CodingProjects/nushell> $a.b.c = 99                                                                            
~/CodingProjects/nushell> $a                                                                                    
╭───┬────────────╮
│   │ ╭───┬────╮ │
│ b │ │ c │ 99 │ │
│   │ ╰───┴────╯ │
╰───┴────────────╯
```

<!--
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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-22 18:51:07 +02:00
WMR
8e538c650e
Fix version to show build features after crateification (#9262)
# Description

Addresses missing features per #9261 

# User-Facing Changes

Fixes output of version.  Adds wasi feature output

 # Tests + Formatting

No tests written

Co-authored-by: Robert Waugh <robert@waugh.io>
2023-05-22 08:42:38 -07:00
WindSoilder
5a34671343
add -u flag to cp, mv command (#9214)
# Description
Closes: #7853

I found that I want this feature too...

So I take over it, sorry for that @VincenzoCarlino 

# User-Facing 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-20 09:48:57 -07:00
Antoine Stevan
9b139330f8
stdlib: fix the names of the help commands in help.nu (#9252)
related to the changes in
- #9193

# Description
when we change the namespace of a module, the internal calls to the
`export`ed commands needs to be updated as well 👀 😆

without this, we have the following pretty error:
```
> std help ansi
Error:   × std::help::item_not_found
   ╭─[entry #1:1:1]
 1 │ std help ansi
   ·          ──┬─
   ·            ╰── item not found
   ╰────
```
2023-05-20 17:37:17 +02:00
pwygab
6564ed710d
allow view-source to read rest arguments (#9247)
# Description
Fixes #8896. Also went back and cleaned up the code slightly.

# User-Facing Changes
`view-source` now is more comprehensive when viewing definitions. 

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-20 08:56:21 -05:00
Maria José Solano
4954a762b7
Allow duration defaults (#9249)
# 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.
-->
Fixes #9217 (some cases, still can't accept all default expressions)

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
- Follow-up of #8940, expanding `eval_constant` so that it can also
evaluate values with units.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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
> ```
-->
- A unit test was added to verify that defaults like `1sec` are
accepted.
2023-05-20 08:23:25 -05:00
Jakub Žádník
429c4332b1
Make aliased call not look up predeclarations (#9244) 2023-05-20 00:46:22 +03:00
pwygab
01a00641f9
Allow input to take a specified number of characters (#9242)
# Description
Title; fixes #9208.


# User-Facing Changes
`input` now can specify a certain number of characters to read.

# Tests + Formatting
No CI tests; can't find a way to implement.
```
~/CodingProjects/nushell> let user_input = (input --numchar 2)                                           
~/CodingProjects/nushell> echo $user_input                                                        
te
```

# 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.
-->
2023-05-19 15:28:35 -05:00
Antoine Stevan
55bb501c71
FEATURE: fix the namespace of the standard library (not testing) (#9193) 2023-05-19 23:27:45 +03:00
Michael Angerman
c55b5c0a55
move dataframe commands to nu-cmd-dataframe (#9241)
All of the dataframe commands ported over with no issues...

### 11 tests are commented out (for now)

So 100 of the original 111 tests are passing with only 11 tests being
ignored for now..

As per our conversation in the core team meeting on Wednesday
I took @jntrnr  suggestion and just commented out the tests dealing
with
[IntoDatetime](https://github.com/nushell/nushell/blob/main/crates/nu-command/src/conversions/into/mod.rs)

Later on we can move this functionality out of nu-command if we decide
it makes sense...

### The following tests were ignored...

```rust
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_day.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_hour.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_minute.rs

modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_month.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_nanosecond.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_ordinal.rs

modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_second.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_week.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_weekday.rs

modified:   crates/nu-cmd-dataframe/src/dataframe/series/date/get_year.rs
modified:   crates/nu-cmd-dataframe/src/dataframe/series/string/strftime.rs
```
2023-05-19 10:56:08 -07:00
Kamil
ca275f59da
Added assert not command (assertion that the value/expression is false) (#9235)
# Description
A new command to simplify assertions for `false`.

The name is just a draft, though I could not come up with a better name.
I have rejected `assert false`, because I would have to rename `assert`
to `assert true` which would break the compatibility and worsen the
shell experience of the good old `assert`.

Another idea I have rejected was something like `assert_false` to keep
it consistent with the naming convention of our stdlib.

I am open to suggestions :)

# User-Facing Changes
Just a new command

# Tests + Formatting
- [x] Done

# 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.
-->
2023-05-19 11:33:19 +02:00
Darren Schroeder
e752d8a964
remove unused dependencies (#9230)
# Description

This is a test PR to see if we can remove dependencies. The crates to
remove was generated from cargo machete. If ci works, I'll update the PR
to remove deps instead of comment them out.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-18 11:37:20 -05:00
Maxim Uvarov
fe1174bf16
add the no-strip flag to the clip command (#9216)
# 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.
-->
`ansi strip` (used in the clip command by default) removes tab symbols,
which is sometimes not useful (for example, when using the `[[a b]; [1
2]] | to tsv | clip` command). Therefore, I added a flag to prevent
using `ansi strip` in the clip command.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-18 13:07:47 +02:00
Mel Massadian
1de57eb2b6
fix: 🐛 handle windows Path casing (#9210)
# 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.
-->

PATH and Path are different (in nushell at least) based on the OS

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

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-17 18:55:46 -05:00
nicolb2305
acd7c98c39
Removes unnecessary cwd and pipeline from various tests (#9202)
# 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.
-->
Cleans up various tests that unnecessarily use the `cwd` argument of
`nu!`, and the `pipeline` function for single line commands. Also
replaces some unnecessary raw strings with normal strings. Part of
#8670.

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

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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
> ```
-->
All checks pass

# 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.
-->
2023-05-17 18:55:26 -05:00
mike
0e4729b203
improve parsing of values with units (#9190)
closes #9111 

# Description

this pr improves parsing of values with units (`filesizes`, `durations`
and any other **future values**) by:

1. allowing underscores in the value part
```nu
> 42kb          # okay
> 42_sec        # okay
> 1_000_000mib  # okay
> 69k_b         # not okay, underscores not allowed in the unit
```

2. improving error messages involving these values
```nu
> sleep 40-sec

# before
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #42:1:1]
 1 │ sleep 40-sec
   ·       ──┬──
   ·         ╰── expected duration with valid units
   ╰────

# now
Error:
  × duration value must be a number
   ╭─[entry #41:1:1]
 1 │ sleep 40-sec
   ·       ─┬─
   ·        ╰── not a number
   ╰────
```

3. unifying parsing of these values. now all of these use one function

# User-Facing Changes

filesizes and durations can now have underscores for readability
2023-05-17 18:54:35 -05:00
Amirhossein Akhlaghpour
6a0c88d516
Fmt f64 (#9142)
Fixes: #9131 
As octal and some other format not valid for f64 we have to specify it .
just wonder if need for generic impl or no for just one type ?
2023-05-17 18:49:07 -05:00
Doru
dacf80f34a
Feature: Userland LazyRecords (#8332)
# Description
Despite the innocent-looking title, this PR involves quite a few backend
changes as the existing LazyRecord trait was not at all friendly towards
the idea of these values being generated on the fly from Nu code.

In particular, here are a few changes involved:
- The LazyRecord trait now involves a lifetime `'a`, and this lifetime
is used in the return value of `get_column_names`. This means it no
longer returns `'static str`s (but implementations still can return
these). This is more stringent on the consumption side.
- The LazyRecord trait now must be able to clone itself via a new
`clone_value` method (as requiring `Clone` is not object safe). This
pattern is borrowed from `Value::CustomValue`.
- LazyRecord no longer requires being serde serializable and
deserializable.

These, in hand, allow for the following:
- LazyRecord can now clone itself, which means that they don't have to
be collected into a Record when being cloned.
- This is especially useful in Stack, which is cloned on each repl line
and in a few other cases. This would mean that _every_ LazyRecord
instance stored in a variable would be collected in its entirety and
cloned, which can be catastrophic for performance. See: `let nulol =
$nu`.
- LazyRecord's columns don't have to be static, they can have the same
lifetime of the struct itself, so different instances of the same
LazyRecord type can have different columns and values (like the new
`NuLazyRecord`)
- Serialization and deserialization are no longer meaningless, they are
simply less.

I would consider this PR very "drafty", but everything works. It
probably requires some cleanup and testing, though, but I'd like some
eyes and pointers first.

# User-Facing Changes
New command. New restrictions are largely internal. Maybe there are some
plugins affected?

Example of new command's usage:
```
lazy make --columns [a b c] --get-value { |name| print $"getting ($name)"; $name | str upcase }
```

You can also trivially implement something like `lazy make record` to
take a record of closures and turn it into a getter-like lazy struct:
```
def "lazy make record" [
    record: record
] {
    let columns = ($record | columns)

    lazy make --columns $columns --get-value { |col| do ($record | get $col) }
}
```

Open to bikeshedding. `lazy make` is similar to `error make` which is
also in the core commands. I didn't like `make lazy` since it sounded
like some transformation was going on.

# Tour for reviewers
Take a look at LazyMake's examples. They have `None` as the results, as
such they aren't _really_ correct and aren't being tested at all. I
didn't do this because creating the Value::LazyRecord is a little tricky
and didn't want to risk messing it up, especially as the necessary
variables aren't available when creating the examples (like stack and
engine state).

Also take a look at NuLazyRecord's get_value implementation, or in
general. It uses an Arc<Mutex<_>> for the stack, which must be accessed
mutably for eval_block but get_value only provides us with a `&self`.
This is a sad state of affairs, but I don't know if there's a better
way.

On the same code path, we also have pipeline handling, and any pipeline
that isn't a Pipeline::Value will return Value::nothing. I believe
returning a Value::Error is probably better, or maybe some other
handling. Couldn't decide on which ShellError to settle with for that
branch.

The "unfortunate casualty" in the columns.rs file. I'm not sure just how
bad that is, though, I simply had to fight a little with the borrow
checker.

A few leftover comments like derives, comments about the now
non-existing serde requirements, and impls. I'll definitely get around
to those eventually but they're in atm

Should NuLazyRecord implement caching? I'm leaning heavily towards
**yes**, this was one of the main reasons not to use a record of
closures (besides convenience), but maybe it could be opt-out. I'd
wonder about its implementation too, but a simple way would be to move a
HashMap into the mutex state and keep cached values there.
2023-05-17 18:35:22 -05:00
Reilly Wood
9ce61dc677
Change group-by to accept cell paths (#9020)
Closes #9003.

This PR changes `group-by` so that its optional argument is interpreted
as a cell path. In turn, this lets users use `?` to ignore rows that are
missing the column they wish to group on. For example:

```
> [{foo: 123}, {foo: 234}, {bar: 345}] | group-by foo
Error: nu:🐚:column_not_found

  × Cannot find column
   ╭─[entry #3:1:1]
 1 │ [{foo: 123}, {foo: 234}, {bar: 345}] | group-by foo
   ·                          ─────┬────             ─┬─
   ·                               │                  ╰── cannot find column 'foo'
   ·                               ╰── value originates here
   ╰────

> [{foo: 123}, {foo: 234}, {bar: 345}] | group-by foo?
╭─────┬───────────────╮
│ 123 │ [table 1 row] │
│ 234 │ [table 1 row] │
╰─────┴───────────────╯
```

~~This removes the ability to pass `group-by` a closure or block (I
wasn't able to figure out how to make the 2 features coexist), and so it
is a breaking change. I think this is OK; I didn't even know `group-by`
could accept a closure or block because there was no example for that
functionality.~~
2023-05-17 18:34:44 -05:00
WindSoilder
b150f9f5d8
Avoid blocking when o+e> redirects too much stderr message (#8784)
# Description

Fixes: #8565

Here is another pr #7240 tried to address the issue, but it works in a
wrong way.

After this change `o+e>` won't redirect all stdout message then stderr
message and it works more like how bash does.

# User-Facing Changes

For the given python code:
```python
# test.py
import sys

print('aa'*300, flush=True)
print('bb'*999999, file=sys.stderr, flush=True)
print('cc'*300, flush=True)
```

Running `python test.py out+err> a.txt` shoudn't hang nushell, and
`a.txt` keeps output in the same order

## About the change
The core idea is that when doing lite-parsing, introduce a new variant
`LiteElement::SameTargetRedirection` if we meet `out+err>` redirection
token(which is generated by lex function),

During converting from lite block to block,
LiteElement::SameTargetRedirection will be converted to
PipelineElement::SameTargetRedirection.

Then in the block eval process, if we get
PipelineElement::SameTargetRedirection, we'll invoke `run-external` with
`--redirect-combine` flag, then pipe the result into save command

## What happened internally?

Take the following command as example:
`^ls o+e> log.txt`

lex parsing result(`Tokens`) are not changed, but `LiteBlock` and
`Block` is changed after this pr.
### LiteBlock before
```rust
LiteBlock {
    block: [
        LitePipeline { commands: [
            Command(None, LiteCommand { comments: [], parts: [Span { start: 39041, end: 39044 }] }),
            // actually the span of first Redirection is wrong too..
            Redirection(Span { start: 39058, end: 39062 }, StdoutAndStderr, LiteCommand { comments: [], parts: [Span { start: 39050, end: 39057 }] }),
        ]
    }]
}
```
### LiteBlock after
```rust
LiteBlock { 
    block: [
        LitePipeline {
            commands: [
                SameTargetRedirection {
                    cmd: (None, LiteCommand { comments: [], parts: [Span { start: 147945, end: 147948}]}),
                    redirection: (Span { start: 147949, end: 147957 }, LiteCommand { comments: [], parts: [Span { start: 147958, end: 147965 }]})
                }
            ]
        }
    ]
}
```
### Block before
```rust
Pipeline {
    elements: [
        Expression(None, Expression {
            expr: ExternalCall(Expression { expr: String("ls"), span: Span { start: 39042, end: 39044 }, ty: String, custom_completion: None }, [], false),
            span: Span { start: 39041, end: 39044 },
            ty: Any, custom_completion: None 
        }),
        Redirection(Span { start: 39058, end: 39062 }, StdoutAndStderr, Expression { expr: String("out.txt"), span: Span { start: 39050, end: 39057 }, ty: String, custom_completion: None })] }
```
### Block after
```rust
Pipeline {
    elements: [
        SameTargetRedirection { 
            cmd: (None, Expression {
                expr: ExternalCall(Expression { expr: String("ls"), span: Span { start: 147946, end: 147948 }, ty: String, custom_completion: None}, [], false),
                span: Span { start: 147945, end: 147948},
                ty: Any, custom_completion: None
            }),
            redirection: (Span { start: 147949, end: 147957}, Expression {expr: String("log.txt"), span: Span { start: 147958, end: 147965 },ty: String,custom_completion: None}
        }
    ]
}
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-05-17 17:47:03 -05:00
WindSoilder
9c435fee75
fix clippy warning on clippy 0.1.69 (#9204)
# Description
As title, when I run clippy locally, I get something like following
warning:
<img width="1383" alt="Screenshot 2023-05-15 at 22 34 57"
src="https://github.com/nushell/nushell/assets/22256154/4d4254bc-9e42-437e-9169-d15e9a97aa57">

This pr is going to fix it

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-17 17:44:08 -05:00
Bob Hyman
ce071f2498
fix spurious 'item not found' error in std help (#9197)
…ses).


# 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.
-->
See title.  
Fixes #9154 
(despite name of branch)

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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
> [x] 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.
-->
2023-05-17 20:02:23 +02:00
Darren Schroeder
057de06613
bump nushell from release version to development version (#9215)
# Description

Bump nushell to 0.80.1 development version

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-17 07:59:01 -05:00
Stefan Holderbach
8695b57584
Bump version for 0.80.0 release (#9212)
# Checklist

- [x] merged reedline PR
- [ ] release notes
2023-05-17 10:11:13 +12:00
Stefan Holderbach
c9652bce00
Pin reedline to 0.19.1 for 0.80 release (#9211)
# Description
This just includes the bracketed paste bugfix in nushell/reedline#577


# User-Facing Changes
None

# Tests + Formatting

# After Submitting
2023-05-17 10:05:24 +12:00
Antoine Stevan
bf86cd50a5
REFACTOR: remove the shell commands (#8415)
Related to #8368.

# Description
as planned in #8311, the `enter`, `shells`, `g`, `n` and `p` commands
have been re-implemented in pure-`nushell` in the standard library.
this PR removes the `rust` implementations of these commands.

- all the "shells" tests have been removed from
`crates/nu-commnand/tests/commands/` in
2cc6a82da6, except for the `exit` command
- `cd` does not use the `shells` feature in its source code anymore =>
that does not change its single-shell behaviour
- all the command implementations have been removed from
`crates/nu-command/src/shells/`, except for `exit.rs` => `mod.rs` has
been modified accordingly
- the `exit` command now does not compute any "shell" related things
- the `--now` option has been removed from `exit`, as it does not serve
any purpose without sub-shells

# User-Facing Changes
users may now not use `enter`, `shells`, `g`, `n` and `p`
now they would have to use the standard library to have access to
equivalent features, thanks to the `dirs.nu` module introduced by @bobhy
in #8368

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
the website will have to be regenerated to reflect the removed commands
👍
2023-05-13 12:40:11 -05:00
Jakub Žádník
8d8304cf91
Allow recursive module dirs; Require mod.nu in dirs (#9185) 2023-05-13 01:20:33 +03:00
Antoine Stevan
92c1051143
fix the span of the global std help item (#9184)
related to 
- #9101
- #9039

# Description
i actually forgot to fix in #9039 the new "*item*" introduced by
#9101... 👀
there it is 😇 

# User-facing changes
going from
```
> std help git-commiteuwqi
Help pages from external command git-commiteuwqi:
No manual entry for git-commiteuwqi
Error:
  × std::help::item_not_found
     ╭─[help:721:1]
 721 │
 722 │     let item = ($item | str join " ")
     ·     ─┬─
     ·      ╰── item not found
 723 │
     ╰────
```
to
```
> std help git-commiteuwqi
Help pages from external command git-commiteuwqi:
No manual entry for git-commiteuwqi
Error:
  × std::help::item_not_found
   ╭─[entry #2:1:1]
 1 │ std help git-commiteuwqi
   ·          ───────┬───────
   ·                 ╰── item not found
   ╰────
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-12 20:30:38 +02:00
Antoine Stevan
9ebb61fc2d
FIX: correct bad span in std help errors (#9039)
# Description
##  before this PR
```
>_ std help modules euwioq
Error: nu:🐚:external_command

  × External command failed
     ╭─[help:259:1]
 259 │         if ($found_module | is-empty) {
 260 │             module_not_found_error (metadata $module | get span)
     ·                                    ──────────────┬──────────────
     ·                                                  ╰── Cannot convert record<start: int, end: int> to a string
 261 │         }
     ╰────
  help: All arguments to an external command need to be string-compatible
```
```
>_ std help externs euwioq
Error:
  × std::help::extern_not_found
     ╭─[help:401:1]
 401 │
 402 │     let extern = ($extern | str join " ")
     ·     ─┬─
     ·      ╰── extern not found
 403 │
     ╰────
```
> **Note**
> same kind of error with all the others

## ✔️ after this PR
```
> std help modules euwioq                                                                                         04/28/2023 05:45:50 PM
Error:
  × std::help::module_not_found
   ╭─[entry #2:1:1]
 1 │ std help modules euwioq
   ·                  ───┬──
   ·                     ╰── module not found
   ╰────
```
```
> std help externs euwioq                                                                                         04/28/2023 05:45:53 PM
Error:
  × std::help::extern_not_found
   ╭─[entry #3:1:1]
 1 │ std help externs euwioq
   ·                  ───┬──
   ·                     ╰── extern not found
   ╰────
```
> **Note**
> same with the others

# User-Facing Changes
fixes the errors to have proper messages

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-12 19:44:39 +02:00
mike
2254805a6d
make the pattern-matcher and eval engine use the same unit computation (#8973)
# Description
this pr adresses
[this](7413ef2824/crates/nu-protocol/src/engine/pattern_match.rs (L149))
'fix me'
2023-05-12 12:18:11 -05:00
tesla232
8584aa79a2
Span fixes during duration conversion (#9143)
Description: Fix of #8945.


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

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: jpaldino <jpaldino@zaloni.com>
2023-05-12 18:57:50 +02:00
mike
a3bf2bff49
improve error when name and parameters are not space-separated (#8958)
# Description
closes #8934

this pr improves the diagnostic emitted when the name and parameters of
either `def`, `def-env` or `extern` are not separated by a space

```nu
Error:
  × no space between name and parameters
   ╭─[entry #1:1:1]
 1 │ def err[] {}
   ·        ▲
   ·        ╰── expected space
   ╰────
  help: consider adding a space between the `def` command's name and its parameters
```

from

```nu
Error: nu::parser::missing_positional

  × Missing required positional argument.
   ╭─[entry #1:1:1]
 1 │ def err[] {}
   ╰────
  help: Usage: def <def_name> <params> <body>
```

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: Jelle Besseling <jelle@pingiun.com>
2023-05-12 09:10:40 -05:00
Hofer-Julian
5e8754bd85
Start to move to polars 0.29 (#9145)
This does part of the work of porting to polars 0.29.
However, I am not familiar enough with this part of the codebase to
finish it.

Things to be done:
- We match two times over `polars::Expr` but `Expr::Cache` isn't
handled. I don't know what should be done here
- `ArgExpr:::List` was renamed to `ArgExpr::Implode`. Does that mean
that `dfr list` should be renamed to `dfr implode`?

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-12 07:44:35 -05:00
JT
a45bd0301a
remove a few unnecessary allocations (#9176)
# Description

Change the parser a little bit so it does less allocations when it's
parsing, specifically when parsing lists/tables

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-12 05:10:54 +02:00
Darren Schroeder
39cdf56214
Update default_env.nu to work with windows (#9172)
# Description
This PR fixes the `create_left_prompt` custom command to work with
Windows.
Before:

![image](https://github.com/nushell/nushell/assets/343840/5a78fc3b-3c2a-4c2f-9c1d-2451063273af)
After:

![image](https://github.com/nushell/nushell/assets/343840/c3785767-5000-454e-9b7b-b0094c3d0834)


# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-11 15:48:56 -05:00
Bob Hyman
9e9fe83bfd
Parameter defaults to $nu.scope.commands (#9152)
(*third* try at posting this PR, #9104, like #9084, got polluted with
unrelated commits. I'm never going to pull from the github feature
branch again!)

# 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.
-->
Show parameter defaults in scope command signature, where they're
available for display by help.
per https://github.com/nushell/nushell/issues/8928.

I found unexpected ramifications in one completer (NuHelpCompleter) and
plugins, which both use the flag-formatting routine from builtin help.
For the moment I made the minimum necessary changes to get the mainline
scenario to pass tests and run. But we should circle back on what to do
with plugins and help completer..

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
1. New `parameter_default` column to `signatures` table in
`$nu.scope.commands`
It is populated with whatever parameters can be defaulted: currently
positional args and named flags.
2. Built in help (both `help <command>` and `<command> --help` will
display the defaults
3. Help completer will display defaults for flags, but not for
positionals.

Example:
A custom command with some default parameters:
```
〉cat ~/work/dflts.nu 
# sample function to show defaults in help
export def main [
    arg1: string        # mandatory positional
    arg2:string=abc     # optional positional
    --switch            # no default here
    --named:int         # named flag, no default
    --other:string=def  # flag 
    --hard:record<foo:int bar:string, bas:bool> # default can be compound type
            = {foo:22, bar:"other worlds", bas:false}
] { {arg1: $arg1,
    arg2: $arg2,
    switch: $switch,
    named: $named,
    other: $other,
    hard: $hard, }
}

〉use ~/work/dflts.nu

〉$nu.scope.commands | where name == 'dflts' | get signatures.0.any | reject short_flag description custom_completion
╭───┬────────────────┬────────────────┬──────────────────────────────────────────┬─────────────┬───────────────────────────╮
│ # │ parameter_name │ parameter_type │               syntax_shape               │ is_optional │     parameter_default     │
├───┼────────────────┼────────────────┼──────────────────────────────────────────┼─────────────┼───────────────────────────┤
│ 0 │                │ input          │ any                                      │ false       │                           │
│ 1 │ arg1           │ positional     │ string                                   │ false       │                           │
│ 2 │ arg2           │ positional     │ string                                   │ true        │ abc                       │
│ 3 │ switch         │ switch         │                                          │ true        │                           │
│ 4 │ named          │ named          │ int                                      │ true        │                           │
│ 5 │ other          │ named          │ string                                   │ true        │ def                       │
│ 6 │ hard           │ named          │ record<foo: int, bar: string, bas: bool> │ true        │ ╭───────┬───────────────╮ │
│   │                │                │                                          │             │ │ foo   │ 22            │ │
│   │                │                │                                          │             │ │ bar   │ other worlds  │ │
│   │                │                │                                          │             │ │ bas   │ false         │ │
│   │                │                │                                          │             │ ╰───────┴───────────────╯ │
│ 7 │                │ output         │ any                                      │ false       │                           │
╰───┴────────────────┴────────────────┴──────────────────────────────────────────┴─────────────┴───────────────────────────╯

〉help dflts
sample function to show defaults in help

Usage:
  > dflts {flags} <arg1> (arg2) 

Flags:
  --switch - switch -- no default here
  --named <Int> - named flag, typed, but no default
  --other <String> - flag with default (default: 'def')
  --hard <Record([("foo", Int), ("bar", String), ("bas", Boolean)])> - default can be compound type (default: {foo: 22, bar: 'other worlds', bas: false})
  -h, --help - Display the help message for this command

Parameters:
  arg1 <string>: mandatory positional
  arg2 <string>: optional positional (optional, default: 'abc')
```

Compared to (relevant bits of) help output previously:
```
Flags:
  -h, --help - Display the help message for this command
  -, --switch - no default here
  -, --named <int> - named flag, no default
  -, --other <string> - flag
  -, --hard <record<foo: int, bar: string, bas: bool>> - default can be compound type

Signatures:
  <any> | dflts <string> <string> -> <any>

Parameters:
  arg1 <string>: mandatory positional
  (optional) arg2 <string>: optional positional
```

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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
> [x] 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.
-->
2023-05-11 13:59:56 -05:00
juanPabloMiceli
e735d0c561
Fix find -v command on tables (issue #9043) (#9159)
# Description
This PR fixes issue #9043 where find -v was returning empty tables
and/or wrong output.
It also refactors some big code chunks with repetitions into it's own
functions.

# User-Facing Changes

# Tests + Formatting
Unit tests added for asserting changes.

# After Submitting
2023-05-11 13:39:21 -05:00
mike
39e51f1953
add more commands to std iter (#9129)
# Description

this pr adds the following commands to `std iter`
- `iter find-index` -> returns the index of the first element that
matches the predicate or `-1` if none
- `iter flat-map` -> maps a closure to each nested structure and
flattens the result
- `iter zip-with` -> zips two structures and applies a closure to each
of the zips

it also fixes some \*\*very minor\*\* inconsistencies in the module
2023-05-10 19:18:42 +02:00
Antoine Stevan
43a3983d36
REFACTOR: move the banner from the rust source to the standard library (#8406)
Related to:
- #8311 
- #8353

# Description
with the new `$nu.startup-time` from #8353 and as mentionned in #8311,
we are now able to fully move the `nushell` banner from the `rust`
source base to the standard library.

this PR
- removes all the `rust` source code for the banner
- rewrites a perfect clone of the banner to `std.nu`, called `std
banner`
- call `std banner` from `default_config.nu`

# User-Facing Changes
see the demo: https://asciinema.org/a/566521

- no config will show the banner (e.g. `cargo run --release --
--no-config-file`)
- a custom config without the `if $env.config.show_banner` block and no
call to `std banner` would never show the banner
- a custom config with the block and `config.show_banner = true` will
show the banner
- a custom config with the block and `config.show_banner = false` will
NOT show the banner

# Tests + Formatting
a new test line has been added to `tests.nu` to check the length of the
`std banner` output.
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
```
$nothing
```

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-10 07:05:01 -05:00
Darren Schroeder
a8b4e81408
add a negation glob option to the glob command (#9153)
# Description
This PR adds the ability to add a negation glob.

Normal Example:
```
> glob **/tsconfig.json
╭───┬────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 0 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\client\node_modules\big-integer\tsconfig.json │
│ 1 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\client\tsconfig.json                          │
│ 2 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\fastq\test\tsconfig.json         │
│ 3 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\node_modules\jszip\tsconfig.json              │
│ 4 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\server\tsconfig.json                          │
│ 5 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\tsconfig.json                                 │
╰───┴────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
Negation Example:
```
> glob **/tsconfig.json --not **/node_modules/**
╭───┬───────────────────────────────────────────────────────────────────────────────╮
│ 0 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\client\tsconfig.json │
│ 1 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\server\tsconfig.json │
│ 2 │ C:\Users\username\source\repos\forks\vscode-nushell-lang\tsconfig.json        │
╰───┴───────────────────────────────────────────────────────────────────────────────╯
```

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-10 06:31:34 -05:00
Michael Albers
6c13c67528
Ensure consistent map ordering when reading YAML (#9155)
# Description

This change ensures that the ordering of map keys when reading YAML
files is consistent. Previously a `HashMap` was used to store the
mappings, but that would result in non-deterministic ordering of the
keys. Switching to an `IndexMap` fixes this.

Fixes https://github.com/nushell/nushell/issues/8662

# User-Facing Changes

User's can rely on consistent ordering of map keys from YAML.

# Tests + Formatting

A unit test ensuring the ordering has been added.

# After Submitting

None.
2023-05-10 06:30:55 -05:00
Steven Xu
2a484a3e7e
fix: use buffer.len() instead of cursor_pos, so the .expect() isn't useless (#9053)
# Description
Use `buffer.len()` instead of `cursor_pos`, so the `.expect()` isn't
useless.

# User-Facing Changes

# Tests + Formatting

# After Submitting
2023-05-08 13:02:01 -05:00
Antoine Stevan
a78cd6e231
FIX: add a space after the default left prompt (#9074)
# Description
when running `nushell` with the `--no-config-file` option, the left
prompt does not have a space to separate the directory path from the
user input.
in this PR i add a space there to make the prompt easier to read when
using `--no-config-file`!

# User-Facing Changes
before: https://asciinema.org/a/581733
after: https://asciinema.org/a/581734

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-08 13:00:44 -05:00
Antoine Stevan
a528c043fe
REFACTOR: fix typos and simplify external std help (#9100)
followup to #9025
cc/ @YummyOreo 

# Description
this PR simply fixes some typos and simplifies the logic of the external
help page opening 😋

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-08 12:59:52 -05:00
Antoine Stevan
47f9fd3644
FIX: have consistent errors between std help and std help ... (#9101)
# Description
an example should show what happens quite clearly 😋 

> **Note**
> the ugly spanned errors you'll see below are fixed in
https://github.com/nushell/nushell/pull/9039 😌

in all cases we get
```
> std help commands does-not-exist-anywhere
Help pages from external command does-not-exist-anywhere:
No manual entry for does-not-exist-anywhere
Error:
  × std::help::command_not_found
     ╭─[help:662:1]
 662 │
 663 │     let command = ($command | str join " ")
     ·     ─┬─
     ·      ╰── command not found
 664 │
     ╰────
```
but

##  before this PR
```
> std help does-not-exist-anywhere
Help pages from external command does-not-exist-anywhere:
No manual entry for does-not-exist-anywhere
```
without any error, which makes it inconsistent with all the other `std
help` commands which give errors when not finding an item 🤔

## ✔️ with this PR
```
> std help does-not-exist-anywhere
Help pages from external command does-not-exist-anywhere:
No manual entry for does-not-exist-anywhere
Error:
  × std::help::item_not_found
     ╭─[help:740:1]
 740 │
 741 │     let item = ($item | str join " ")
     ·     ─┬─
     ·      ╰── item not found
 742 │
     ╰────
```

# User-Facing Changes
more consistent errors when using `std help` and `std help commands`, as
shown above.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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
```
$nothing
```
2023-05-08 12:58:49 -05:00
Antoine Stevan
fe9f732c5f
REFACTOR: make input list a tiny bit tighter (#9115)
related to #8963
cc/ @melMass 

# Description
just a little refactoring attempt for `input list` 😌 

i wanted to refactor even more, but `Select`, `MultiSelect` and
`FuzzySelect` do not share a common trait, i could not find a nice way
to reduce the big `if` block...

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-08 12:45:55 -05:00
Maxim Zhiburt
a5d02a0737
nu-explore: Fix repeated char issue in cmdline (#9139)
Must be fixed; (though I'd test it)

Thanks for the reference [fdncred](https://github.com/fdncred).

close #9128

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-08 12:38:42 -05:00
Antoine Stevan
7a945848de
swap the date and the log level in the std log format (#9138)
related to
https://github.com/nushell/nushell/issues/8588#issuecomment-1538624565

# Description
this PR switches the date and log level in `std log` 👍 

# User-Facing Changes
the date and log level are now swapped in the `std log` format.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-08 12:29:18 -05:00
Maxim Zhiburt
a92949b5c3
nu-explore: Fix pipeline rendering (#9137)
Must be fixed (but I would check).

I wonder if it was a regression caused by `Value::LazyRecord`.
I mean likely the issue was before the refactoring I did.

close #9130

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-05-08 11:17:14 -05:00
Hofer-Julian
d5ae979094
Update polars to 0.28 (#9136)
# Description
Update polars to 0.28.
Luckily, it didn't require major changes.

# User-Facing Changes
None.
(Apart from the fact that certain error messages will stop breaking
table formatting)
2023-05-08 10:42:53 -05:00
Darren Schroeder
388e84e7ef
update nu-glob based on latest glob 0.3.1 changes (#9099)
# Description
This PR updates `nu-glob` to add the latest changes and updates from
`rust-lang/glob` [v0.3.1](https://github.com/rust-lang/glob).

With these changes you can do this type of globbing
```rust
/// - `?` matches any single character.
///
/// - `*` matches any (possibly empty) sequence of characters.
///
/// - `**` matches the current directory and arbitrary subdirectories. This
///   sequence **must** form a single path component, so both `**a` and `b**`
///   are invalid and will result in an error.  A sequence of more than two
///   consecutive `*` characters is also invalid.
///
/// - `[...]` matches any character inside the brackets.  Character sequences
///   can also specify ranges of characters, as ordered by Unicode, so e.g.
///   `[0-9]` specifies any character between 0 and 9 inclusive. An unclosed
///   bracket is invalid.
///
/// - `[!...]` is the negation of `[...]`, i.e. it matches any characters
///   **not** in the brackets.
///
/// - The metacharacters `?`, `*`, `[`, `]` can be matched by using brackets
///   (e.g. `[?]`).  When a `]` occurs immediately following `[` or `[!` then it
///   is interpreted as being part of, rather then ending, the character set, so
///   `]` and NOT `]` can be matched by `[]]` and `[!]]` respectively.  The `-`
///   character can be specified inside a character sequence pattern by placing
///   it at the start or the end, e.g. `[abc-]`.
```
Example - with character sequences

![image](https://user-images.githubusercontent.com/343840/236266670-03bf9384-4917-4074-9687-2c1c0d8ef34a.png)

Example - with character sequence negation

![image](https://user-images.githubusercontent.com/343840/236266421-73c3ee2c-1d10-4da0-86be-0afb51b50604.png)

Example - normal globbing

![image](https://user-images.githubusercontent.com/343840/236267138-60f22228-b8d3-4bf2-911b-a80560fdfa4f.png)

Example - with character sequences

![image](https://user-images.githubusercontent.com/343840/236267475-8c38fce9-87fe-4544-9757-34d319ce55b8.png)

Not that, if you're using a character sequence by itself, you need to
enclose it in quotes, otherwise nushell will think it's a range. But if
you already have a type of a bare word already, no quotes are necessary,
as in the last example.

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-08 09:07:01 -05:00
Emily Grace Seville
a2dd948e71
FEATURE: format std log and add --short option (#9091)
# Description
- prettify formatting
- move message formatting to a private function
- allow short prefixes for loggers via `--short|-s` flag

# User-Facing Changes
- allow short prefixes for loggers via `--short|-s` flag

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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: amtoine <stevan.antoine@gmail.com>
2023-05-08 10:13:21 +02:00
Jakub Žádník
250071939b
Reuse parsed modules (#9125) 2023-05-07 14:41:40 +03:00
Jakub Žádník
0ea973b78b
Fix exported module not found (#9121) 2023-05-06 23:55:10 +03:00
Jakub Žádník
a2a346e39c
Allow creating modules from directories (#9066) 2023-05-06 21:39:54 +03:00
Antoine Stevan
6dc7ff2335
FEATURE: return tables with std help ... --find ... (#9040)
# Description
this PR makes `std help` commands return a table no matter the number of
matches when using `--find`.
as proposed by Darren, this would allow users to still rely on things
like
```nushell
let blah = (std help modules -f weather | get name)
```
even if there is a single match.

# User-Facing Changes
`std help ... --find ...` now returns a table as `help ... --find ...`

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-05 18:06:48 +02:00
Mel Massadian
10d65b611f
adds a list subcommand to input (interactive selections) (#8963)
# Description
Adds a subcommand `list` to `input` (can be migrated wherever if needed)
that allows interactive single and multi selection from an input list.

![image](https://user-images.githubusercontent.com/7041726/236072161-5954dad9-8152-4752-ae3b-b21577711fd1.png)



https://user-images.githubusercontent.com/7041726/233747242-1ca6c44b-e32c-48f1-8fa8-ae50f813be16.mp4


In case it's not clear, only the results are captured (for now the
results are also printed to stderr next to the prompt)


https://user-images.githubusercontent.com/7041726/233785814-f2c8c584-9dd4-4b26-9ae9-c819ed6aa954.mp4


# User-Facing Changes
- Adds a new command `input list`
# Tests + Formatting
Not sure how we can test interactives any ideas?

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-04 19:14:41 +02:00
YummyOreo
edb61fc1d5
Try to show help pages for external commands w/ help command (#9025)
# 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.
-->
Makes in so if you run `std help <external>` it will run `man <command>`
to get help pages. This command is configurable w/ the `$env.NU_HELPER`
var.

This will close #8032

Examples:
`std help rg` will display the ripgrep help pages

Todo:
- [x] Make flags and fallback configurable
- [x] Improve the warning that it is external
- [ ] Implement `--find` for external commands

# User-Facing Changes
Users will now be able to run `std help` on external commands

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-04 18:34:07 +02:00
Kamil
155de9f6fc
Added log custom command & exported log levels (#9055)
# Description
- Log levels are now exported members of `std log`, e.g. `std log
CRITICAL_LEVEL`
- Added `std log custom` command that allows to declare custom message
format (actual message replaces `%MSG%` in the template) with
user-defined log level.


# User-Facing Changes
New possibilities included in description

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-04 18:30:15 +02:00
Antoine Stevan
b82e279f9d
REFACTOR: remove deprecated commands (old-alias) (#9056)
# Description
as stated in the `0.79` release note, this PR removes the `old-alias`
and `export old-alias` commands, which were deprecated before.

# User-Facing Changes
`old-alias` is gone for good 😌 

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
already mentionned in the `0.79` release note.
2023-05-04 00:08:07 +02:00
Antoine Stevan
6bbe5b6255
REFACTOR: move source out of deprecated commands (#9060)
# Description
the plan of deprecating `source` never really came to conclusion, so i
propose to move it out of the deprecated commands in this PR.
i've moved it to `nu-command::misc`, which can be changed 👍 

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-04 00:02:03 +02:00
Emily Grace Seville
1019acb7a3
FEATURE: highlight some prompt parts (#9094)
# Description
- highlight directory separators with light green (for regular user) and
light red (for admin) colors respectively
- highlight colons and slashes in the right prompt with light magenta
- underline AM/PM in the right prompt
- use long options to enhance readability

How it looks in MATE Terminal with Tango color theme:


![image](https://user-images.githubusercontent.com/42812113/236052908-fc80def9-9117-4b87-8ce4-321b937f3339.png)



# User-Facing Changes
- highlight directory separators in light green (for regular user) and
red colors (for admin)
- highlight colons and slashes in the right prompt with light magenta
- underline AM/PM in the right prompt

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-03 16:36:27 -05:00
Erich Gubler
83b1ec83c9
feat(rm)!: use arg. spans for I/O errors (#8964)
# Description

Currently, error spans for I/O errors in an `rm` invocation always point
to the `rm` argument. This isn't ideal, because the user loses context
as to which “target” actually had a problem:


![image](https://user-images.githubusercontent.com/658538/235723366-50db727e-9ba2-4d16-afc6-6a2406c584e0.png)

Shadow the existing `span` variable in outer scope in `rm`'s
implementation for the errors that may be detected while handling I/O
results. This is desired, because all failures from this point are
target-specific, and pointing at the argument that generated the target
instead is better. The end user should now see this:


![image](https://user-images.githubusercontent.com/658538/235724345-1d2e98e0-6b20-4bf5-b8a2-8b4368cdfb05.png)

# User-Facing Changes
* When `rm` encounters I/O errors, their spans now point to the “target”
argument associated with the error, rather than the `rm` token.

# Tests + Formatting


No tests currently cover this. I'm open to adding tests, but adding as
follow-up sounds better ATM, since this wasn't covered before.

# After Submitting

Nothing needs to be done here, AFAIK. No I/O errors are currently
demonstrated in official docs, though maybe they should be?
2023-05-03 23:12:16 +02:00
Maria José Solano
d9a00a876b
Change type of flag defaults to Option<Value> (#9085)
# Description
Follow-up of #8940. As @bobhy pointed out, it makes sense for the
behaviour of flags to match the one for positional arguments, where
default values are of type `Option<Value>` instead of
`Option<Expression>`.

# User-Facing Changes
The same ones from the original PR:
- Flag default values will now be parsed as constants.
- If the default value is not a constant, a parser error is displayed.

# Tests + Formatting

A [new
test](e34e2d35f4/src/tests/test_engine.rs (L338-L344))
has been added to verify the new restriction.
2023-05-03 23:09:36 +02:00
WindSoilder
e4625acf24
support bracketed paste (#8907)
# Description

Relative: #8113, #7630
It works on non-windows system

This pr depends on https://github.com/nushell/reedline/pull/571
2023-05-03 23:08:47 +02:00
juanPabloMiceli
7fb48b9a2f
Fix negative precision round with ints (issue #9049) (#9073)
# Description
Before this PR, `math round` ignores the input if it's an `int`. This
results in the following behaviour:
```
> 123 | math round --precision -1
123
```
When the correct result is 120.

Now `int values` are converted to `float values` before actually
rounding up the number in order to take advantage of the float
implementation.

Fixes #9049.
2023-05-03 23:07:32 +02:00
Amirhossein Akhlaghpour
5fcbefb7b4
Feat: listen for signal on glob command (#9088)
Fixes : #9002 

listen for signal cancel .
other way is in listening parallel for ctrl+c wit Arc and mps channels
if this way is not a profit
2023-05-03 21:51:25 +02:00
WindSoilder
345cdef113
Fix overlay's help message lead to internal error (#9087) 2023-05-03 14:08:54 +03:00
Jelle Besseling
a7c1b363eb
Don't run .sh files with /bin/sh (#8951)
# Description

The previous behaviour broke for me because I didn't have `sh` in my
path for my nu script. I think we shouldn't assume that just because a
file ends with `.sh` it should be executed with `sh`. `sh` might not be
available or the script might contain a hashbang for a different shell.

The idea with this PR is that nushell shouldn't assume anything about
executable files and just execute them. Later on we can think about how
non-executable files should be executed if we detect they are a script.

# User-Facing Changes

This may break some people's scripts or habits if they have wrong
assumptions about `.sh` files. We can tell them to add a hashbang and +x
bit to execute shell scripts, or prepend `bash`. If this a common
assumption something like this should be added to the book

# Tests + Formatting

I only tested manually and that did work

# After Submitting

Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-05-02 17:56:35 -05:00
sam schick
d45e9671d4
Suggest existing variables on not found (#8902) 2023-05-02 18:17:14 +03:00
Antoine Stevan
517dc6d39e
pass std bench into table -e in the example (#9075)
cc/ @fdncred 

# Description
in the examples of `std bench` there is an expanded table without
explicitely expanding it...
this PR adds a `table -e` to the `std bench` call in the example.

# User-Facing Changes
the help page of `std bench` now does make sense 😌 

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-05-01 08:18:51 -05:00
Darren Schroeder
e590d3587c
enable history isolation (#9063)
# Description
This PR impacts the nushell sqlite history only.

This is the first PR that enables history isolation in nushell for the
sqlite history. Hopefully, we can continue building on this.

This PR allows "history isolation" which means that other nushell
session's history won't be available in the current session when using
the uparrow/downarrow history navigation. This change only impacts the
uparrow downarrow history navigation.

What remains to be done is making ctrl+r history menu respect this
setting too. Right now, the history menu will still show you all entries
from all sessions.

The history command also shows all history items from all sessions. This
may remain unchanged since you can just filter by history session right
now.

This also fixes a bug where the session id is 0 in the sqlite history
since my April 18th reedline PR.

Closes #9064

# 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 -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-05-01 08:11:38 -05:00
Maxim Zhiburt
9804cd82f8
Fix #9038 (#9042)
close #9038

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-04-28 12:50:42 -05:00
Antoine Stevan
59b85e549c
FIX: filter the std help ... by name, usage and search terms (#9035)
Should close on of the points in
- https://github.com/nushell/nushell/issues/8813

# Description
this PR uses the new `--columns` option for `find` to filter the results
of the `std help` commands on the `usage`, `name` and `search_terms`
columns.

# User-Facing Changes
the `--find` option of `std help` commands should match more closely the
built-in `help` commands output.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-28 12:29:47 -05:00
Antoine Stevan
dae4a9b091
FIX: give same order in std help ... as in help ... (#9034)
Should close on of the points in
- https://github.com/nushell/nushell/issues/8813

# Description
before this PR, we had a problem
```
cargo run -- -c '{
     modules: ((help modules | get name) == (std help modules | get name))
     aliases: ((help aliases | get name) == (std help aliases | get name))
     externs: ((help externs | get name) == (std help externs | get name))
     operators: ((help operators | get name) == (std help operators | get name))
     commands: ((help commands | get name) == (std help commands | get name))
}'
```
would give
```
╭───────────┬───────╮
│ modules   │ false │
│ aliases   │ true  │
│ externs   │ true  │
│ operators │ false │
│ commands  │ true  │
╰───────────┴───────╯
```

this PR removes the `name` sorting so that the orders are the same
between the `std` implementation and the built-in one.

> **Note**
> run the same `cargo run` command as above and see
> ```
> ╭───────────┬──────╮
> │ modules   │ true │
> │ aliases   │ true │
> │ externs   │ true │
> │ operators │ true │
> │ commands  │ true │
> ╰───────────┴──────╯
> ```

# User-Facing Changes
the operators in `std help ...` will be sorted just as the built-in
`help ...`.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-28 09:22:23 -05:00
Jelle Besseling
4ca47258a0
Add --redirect-combine option to run-external (#8918)
# Description

Add option that combines both output streams to the `run-external`
command.

This allows you to do something like this:

```nushell
let res = do -i { run-external --redirect-combine <command that prints to stdout and stderr> } | complete

if $res.exit_code != 0 {
  # Only print output when command has failed.
  print "The command has failed, these are the logs:"
  print $res.stdout
}
```

# User-Facing Changes

No breaking changes, just an extra option.

# Tests + Formatting

Added a test that checks the new option

# 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: Jelle Besseling <jelle@bigbridge.nl>
2023-04-28 07:55:48 -05:00
Steven Xu
b37662c7e1
fix: fix cursor position when cursor is at the end of the commandline (#9030)
# Description
Fix getting the cursor position, when it's at the end of the
commandline.

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

# Tests + Formatting

# After Submitting
2023-04-28 07:02:45 -05:00
Reilly Wood
3076378373
Slim down tests (#9021)
This PR just tidies up some tests by removing unused code:

1. If the filesystem is not touched, don't use the filesystem
playground/sandbox
2. If the filesystem is not touched, don't specify the `cwd`
3. If the command is short, don't bother wrapping it in `pipeline()`
4. If the command doesn't have quotes, don't bother with a `r#"..."#`
raw string

Part of #8670.
2023-04-28 13:25:44 +02:00
Antoine Stevan
35c8485442
FEATURE: add --expand to std clip (#8970)
# Description
i use `std clip` to copy everything from `nushell`.
however i have the auto-expand on tables enabled and when i use `clip`
on large tables, it does not copy what i see but the collapsed data => i
have to edit the line and add `| table --expand` manually, which is a
pain to do regularly 😱

in this PR, i just add `--expand` to `std clip` to automatically expand
the data before copying it 😋

# User-Facing Changes
exploring the `Cargo.toml` of `nushell` with auto-expand, one might see
```
> open Cargo.toml | get package.metadata.binstall.overrides
╭────────────────────────┬───────────────────╮
│                        │ ╭─────────┬─────╮ │
│ x86_64-pc-windows-msvc │ │ pkg-fmt │ zip │ │
│                        │ ╰─────────┴─────╯ │
╰────────────────────────┴───────────────────╯
```
but then
```
open Cargo.toml | get package.metadata.binstall.overrides | clip
```
would only copy
```
╭────────────────────────┬──────────────────╮
│ x86_64-pc-windows-msvc │ {record 1 field} │
╰────────────────────────┴──────────────────╯
```
...

now 
```
open Cargo.toml | get package.metadata.binstall.overrides | clip --expand
```
will copy the expanded record 👍 

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-28 09:07:38 +02:00
Antoine Stevan
3268ecd116
FEATURE: add the bench command to the standard library (#8969)
Should address the first point of
- https://github.com/nushell/nushell/issues/8696.

# Description
i've seen a few appearances of this `benchmark` idea in recent works on
`nu-std`, so i thought it would be great to add it finally.

# User-Facing Changes
a new `std bench` command to measure the performance of `nushell`
closures and code blocks.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-28 09:07:23 +02:00
Jelle Besseling
44493dac51
Add extern def which allows raw arguments (#8956)
# Description

Extends the `extern` syntax to allow commands that accept raw arguments.
This is mainly added to allow wrapper type scripts for external
commands.

This is an example on how this can be used:

```nushell
extern foo [...rest] { 
  print ($rest | str join ',' ) 
}
foo --bar baz -- -q -u -x
# => --bar,baz,--,-q,-u,-x
```

(It's only possible to accept a single ...varargs argument in the
signature)

# User-Facing Changes

No breaking changes, just extra possibilities.

# Tests + Formatting

Added a test for this new behaviour and ran the toolkit pr checker

# After Submitting

This is advanced functionality but it should be documented, I will open
a new PR on the book for that

Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-04-28 09:06:43 +02:00
TrMen
6f9b9914cf
Add more examples to help use (#9024)
# Description
The `members` parameter of `use` is specified as type `any`, but it's
really a string or list of strings or `*`. So add some examples that
mention what you can specify for `members`.

Also mention `help modules` and `help std`, since you probably want to
use the standard library or another defined modules.

Sidenote: I tried to run the examples for `use` as tests like is done
for the other commands. That panics with `missing module command`. I
assume this is known.

# User-Facing Changes
`help use` now looks like this:
```nushell
Use definitions from a module, making them available in your shell.

See `help std` for the standard library module.
See `help modules` to list all available modules.

This command is a parser keyword. For details, check:
  https://www.nushell.sh/book/thinking_in_nu.html

Usage:
  > use <module> (members)

Flags:
  -h, --help - Display the help message for this command

Parameters:
  module <string>: Module or module file
  (optional) members <any>: Which members of the module to import

Examples:
  Define a custom command in a module and call it
  > module spam { export def foo [] { "foo" } }; use spam foo; foo
  foo

  Define a custom command that participates in the environment in a module and call it
  > module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR
  BAZ

  Use a plain module name to import its definitions qualified by the module name
  > module spam { export def foo [] { "foo" }; export def bar [] { "bar" } }; use spam; (spam foo) + (spam bar)
  foobar

  Specify * to use all definitions in a module
  > module spam { export def foo [] { "foo" }; export def bar [] { "bar" } }; use spam *; (foo) + (bar)
  foobar

  To use commands with spaces, like subcommands, surround them with quotes
  > module spam { export def 'foo bar' [] { "baz" } }; use spam 'foo bar'; foo bar
  baz

  To use multiple definitions from a module, wrap them in a list
  > module spam { export def foo [] { "foo" }; export def 'foo bar' [] { "baz" } }; use spam ['foo', 'foo bar']; (foo) + (foo bar)
  foobaz
```
2023-04-27 15:58:07 -05:00
Darren Schroeder
ffb9ab9eef
Update rust-toolchain.toml to 1.67.1 (#9012)
# Description
This PR bumps the rust toolchain from 1.66.1 to 1.67.1

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-27 09:31:29 -05:00
TrMen
ecc820a8c1
Fix unexpected flattening of data by par-each (Issue #8497) (#9007)
# Description
Previously, `par-each` acted like a `flatmap`: first mapping the data,
then applying a `flatten`. This is unlike `each`, which just maps the
data. Now `par-each` works like `each` in this regard, leaving nested
data unflattened.

Fixes #8497

# User-Facing Changes
Previously:
`[1 2 3] | par-each {|e| [$e, $e] }` --> `[1,1,2,2,3,3]` 
Now:
`[1 2 3] | par-each {|e| [$e, $e] }` --> `[[1,1],[2,2],[3,3]]`

# Tests
This adds one test that verifies the lack of flattening for `par-each`.
2023-04-26 23:27:27 +02:00
Darren Schroeder
6047b04208
fix compilation error (#9016)
# Description
This PR fixes a problem due to me landing an out of date PR that stopped
nushell from compiling.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-26 14:38:09 -05:00
Maxim Zhiburt
8d8b011702
Bump tabled dependency to 0.11 (#8922)
close? #8060

Quite a bit of refactoring took place.
I believe a few improvements to collapse/expand were made.

I've tried to track any performance regressions and seems like it is
fine.

I've noticed something different now with default configuration path or
something in this regard?
So I might missed something while testing because of this.

Requires some oversight.

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-04-26 13:56:10 -05:00
goldfish
c422c6cc3d
Fix completion on $nu to show correct menus (#8919)
I'm still new to nushell and Rust, so please let me know if there are
any omissions and/or mistakes.

# Description

fixed #8863
`$nu` completion shows wrong completion menus at this time.
This PR fixes the problem to show the correct ones.

# User-Facing Changes

Users can use the correct menus on `$nu` completion like this
[recording](https://asciinema.org/a/KCwfpdAoMFsQODFBnb3NwmufC).

# Tests + Formatting

```
$ use toolkit.nu
$ toolkit check pr

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

# After Submitting

nothing
2023-04-26 09:15:27 -05:00
Maria José Solano
e251f3a0b4
Change type of parameter default values to Option<Value> (#8940)
# Description

Fixes #8939.

# User-Facing Changes

- Parameter default values will now be parsed as constants.
- If the default value is not a constant, a parser error is displayed.

# Tests + Formatting

The [only affected
test](d42c2b2dbc/src/tests/test_engine.rs (L325-L328))
has been updated to reflect the new behavior.
2023-04-26 09:14:02 -05:00
mike
77ca73f414
allow records to have type annotations (#8914)
# Description
follow up to #8529
cleaned up version of #8892 

- the original syntax is okay
```nu
def okay [rec: record] {}
```
- you can now add type annotations for fields if you know
  them before hand
```nu
def okay [rec: record<name: string>] {}
```

- you can specify multiple fields
```nu
def okay [person: record<name: string age: int>] {}

# an optional comma is allowed
def okay [person: record<name: string, age: int>] {}
```

- if annotations are specified, any use of the command will be type
  checked against the specified type
```nu
def unwrap [result: record<ok: bool, value: any>] {}

unwrap {ok: 2, value: "value"}

# errors with

Error: nu::parser::type_mismatch

  × Type mismatch.
   ╭─[entry #4:1:1]
 1 │ unwrap {ok: 2, value: "value"}
   ·         ───────┬─────
   ·                    ╰── expected record<ok: bool, value: any>, found record<ok: int, value: string>
   ╰────
```
> here the error is in the `ok` field, since `any` is coerced into any
type
> as a result `unwrap {ok: true, value: "value"}` is okay

- the key must be a string, either quoted or unquoted
```nu
def err [rec: record<{}: list>] {}

# errors with
Error:
  × `record` type annotations key not string
   ╭─[entry #7:1:1]
 1 │ def unwrap [result: record<{}: bool, value: any>] {}
   ·                            ─┬
   ·                             ╰── must be a string
   ╰────
```

- a key doesn't have to have a type in which case it is assumed to be
`any`
```nu
def okay [person: record<name age>] {}

def okay [person: record<name: string age>] {}
```

- however, if you put a colon, you have to specify a type
```nu
def err [person: record<name: >] {}

# errors with
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #12:1:1]
 1 │ def unwrap [res: record<name: >] { $res }
   ·                             ┬
   ·                             ╰── expected type after colon
   ╰────
```

# User-Facing Changes
**[BREAKING CHANGES]**
- this change adds a field to `SyntaxShape::Record` so any plugins that
used it will have to update and include the field. though if you are
unsure of the type the record expects, `SyntaxShape::Record(vec![])`
will suffice
2023-04-26 08:16:55 -05:00
Amirhossein Akhlaghpour
48c75831fc
Flags and args on def (#8953)
# Description

Fixes #8916 
Fix flags and args on def which were call wrong .
Added some tests too .
2023-04-26 08:16:32 -05:00
Darren Schroeder
4b8a259916
update ast to support output to json (#8962)
# Description
This PR changes the `ast` command to be able to output `--json` as well
as `nuon` (default) with "pretty" and "minified" output. I'm hoping this
functionality will be usable in the vscode extension for semantic
tokenization and highlighting.

# User-Facing Changes
There's a new `--json`/`-j` option. Prior version output of nuon is
maintained as default.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-26 08:15:42 -05:00
WindSoilder
5733a13409
support blink cursor, and fix underscore's cursorshape (#8990)
# Description
Close: #8988

Thanks to new crossterm version, nushell can support blink cursor shape.
It can be config with the following value:
1. blink_block
2. blink_line
3. blink_underscore

And original block, line, underscore will be steady. It also fixes wrong
shape of `underscore`.

# User-Facing Changes
Here is a little breaking change, before the change: `line` cursor shape
is blinking line, but after this pr, it will be `steady line`. To make a
blink line, we need to change the value to `blink_line`.

But I think it's ok, because after the change, we have a good naming
convention about the name of shape

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-26 08:14:50 -05:00
Steven Xu
66b5931438
fix: set the initial repl cursor pos, fixes #8943 (#8955)
# Description
Set the initial repl cursor pos, so running `commandline --insert`
inserts at the current cursor position of the input buffer.



Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-04-26 01:08:11 +02:00
WindSoilder
503052b669
using ratatui instead of tui (#8952)
# Description

Refer to https://github.com/fdehau/tui-rs/issues/654, I found that tui
maybe un-maintained, instead, I'd suggest to use an actively fork
https://github.com/tui-rs-revival/ratatui

cc: @zhiburt 

# User-Facing Changes
NaN
2023-04-26 01:07:23 +02:00
Stefan Holderbach
7d6a32c5f8
Bump to 0.79.1 dev version (#8998)
# Description

For development or hotfixes
2023-04-26 01:05:23 +02:00
Stefan Holderbach
a1b7261121
Bump version for 0.79.0 release (#8980) 2023-04-25 23:06:17 +03:00
Stefan Holderbach
5a4b6f0f7f
Pin reedline to 0.19.0 release (#8996)
# Description
See release notes:

https://github.com/nushell/reedline/releases/tag/v0.19.0
2023-04-25 20:58:33 +02:00
Reilly Wood
7413ef2824
Tweak run-external signature so command must be a string (#8971)
Tiny fix: clarify in `run-external`'s signature that the external
command must be a string.

### Before
```
Signatures:
  <any> | run-external <any> -> <any>

Parameters:
  command <any>: external command to run
  ...args <any>: arguments for external command
```

### After
```
Signatures:
  <any> | run-external <string> -> <any>

Parameters:
  command <string>: external command to run
  ...args <any>: arguments for external command
```


### Notes

I was hoping to change more `any`s to more specific types, but alas I
think we can only change `command` right now. The input can be any type
and it gets rendered to a string before being passed to the external.
The args can be any value type and they get converted to strings. The
output can be either binary or a string.
2023-04-22 10:57:16 -07:00
JT
d00038eb4b
Reuse the cached parse results of parsed files (#8949)
# Description

This does a lookup in the cache of parsed files to see if a span can be
found for a file that was previously loaded with the same contents, then
uses that span to find the parsed block for that file. The end result
should, in theory, be identical but doesn't require any reparsing or
creating new blocks/new definitions that aren't needed.

This drops the sg.nu benchmark from:
```
╭───┬───────────────────╮
│ 0 │ 280ms 606µs 208ns │
│ 1 │ 282ms 654µs 416ns │
│ 2 │ 252ms 640µs 541ns │
│ 3 │  250ms 940µs 41ns │
│ 4 │ 241ms 216µs 375ns │
│ 5 │ 257ms 310µs 583ns │
│ 6 │ 196ms 739µs 416ns │
╰───┴───────────────────╯
```

to:
```
╭───┬───────────────────╮
│ 0 │ 118ms 698µs 125ns │
│ 1 │       121ms 327µs │
│ 2 │ 121ms 873µs 500ns │
│ 3 │  124ms 94µs 708ns │
│ 4 │ 113ms 733µs 291ns │
│ 5 │ 108ms 663µs 125ns │
│ 6 │  63ms 482µs 625ns │
╰───┴───────────────────╯
```

I was hoping to also see some startup time improvements, but I didn't
notice much there.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-22 07:00:33 +12:00
Bob Hyman
24b4ac692e
std run-tests: Rename --command switch to --test; and likewise in --list output (#8895)
# 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.
-->
As described in #8893, switch `std run-tests --module` is ambiguous, but
`--command` is misleading. Fix that, and rename `--list` output column
to match.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
* `std run-tests --command test_foo_1` changes to `std run-tests --test
test_foo_1`, users may have to change existing scripts (or muscle
memory).
*
  ```
  〉std run-tests --list | columns
  ╭───┬────────╮
  │ 0 │ module │
  │ 1 │ name   │
  │ 2 │ file   │
  ╰───┴────────╯
  ```
  Changes to:
  
  ```
  〉std run-tests --list | columns
  ╭───┬────────╮
  │ 0 │ module │
  │ 1 │ test   │
  │ 2 │ file   │
  ╰───┴────────╯
  
  ```
# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-20 19:41:33 -05:00
mike
fb72da0e82
unify the *-BuiltinVar parser errors (#8944)
# Description

this pr condenses `MutBuiltinVar`, `LetBuiltinVar` and `ConstBuiltinVar`
into one error:
```nu
Error: nu::parser::name_is_builtin_var

  × `in` used as variable name.
   ╭─[entry #69:1:1]
 1 │ let in = 420
   ·     ─┬
   ·      ╰── already a builtin variable
   ╰────
  help: 'in' is the name of a builtin Nushell variable and cannot be used
        as a variable name
```

it also fixes this case which was previously not handled
```nu
let $nu = 420 # this variable would have been 'lost'
```
2023-04-20 19:44:31 +02:00
Antoine Stevan
d339902dc6
stdlib: fix the clip command with integer values (#8898)
# Description
this PR fixes the `std clip` command which would not copy integer data
😮
and, as all the input data is now treated as raw `string` with the
`table | into string` conversion, i've removed the "stripped" print when
done clipping the data 👍

 from the `main` on which this PR is based (cbedc8403)
> **Note**
> from inside`cargo run` and with a `use std clip`
- ✔️ `'foo' | clip`
- ✔️ `ls | get 0 | clip`
-  `123 | clip`
 
# User-Facing Changes
✔️ from the tip of the PR branch
> **Note**
> from inside`cargo run` and with a `use std clip`
- ✔️ `'foo' | clip`
- ✔️ `ls | get 0 | clip`
- ✔️ `123 | clip`

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-20 18:59:34 +02:00
Darren Schroeder
393f424f1c
allow find command to look in specified columns only (#8937)
# Description
This PR allows the `find` command to search in specific columns using
`--columns [col1 col2 col3]`. This is really meant to help with the
`help` command in the std.nu.

There are a few more things I want to look at so this is a draft for
now.
- [x] add example
- [x] look at regex part

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-20 08:13:12 -05:00
Jelle Besseling
c8f54476c9
Set env in exec command (#8917)
# Description

Previously variables with `let-env` were not available after doing an
`exec` command. This PR fixes that

# User-Facing Changes

Can now use environment variables set with nushell after `exec`

# Tests + Formatting

No tests made but formatting has been checked

# 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: Jelle Besseling <jelle@bigbridge.nl>
2023-04-20 22:10:46 +12:00
Antoine Stevan
d42c2b2dbc
refactor the CONTRIBUTING.md guidelines for nu-std (#8912)
## Description
just a little refactor of `CONTRIBUTING.md` of the standard library in
`nu-std`.
- see the new version
[here](https://github.com/amtoine/nushell/blob/stblib/refactor/CONTRIBUTING-guidelines/crates/nu-std/CONTRIBUTING.md).

> **Note**
> actually, that one might be best reviewed commit by commit 😋 
> i tried to be as explicit as possible 😌 

- i fixed the width to `80` columns
- cc/ @bobhy, if you want to jump in and find broken links / bad changes
2023-04-19 22:21:27 +02:00
mike
ed64a44b82
add filter-map command to std iter (#8926)
# Description
as title says
2023-04-19 19:09:10 +02:00
Máté FARKAS
1855dfb656
Fix into decimal command category (#8932)
Commands like this one belong to conversions category

Fixes #8931

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-04-19 11:39:12 -05:00
mike
91c01bf6b3
add iter module to standard library (#8899)
# Description
 
this pr introduces an `iter` module
to the standard library.

the module is aimed at extending the filter commands.
2023-04-18 16:01:36 -05:00
Darren Schroeder
29256b161c
fix reedline breaking changes due to PR562 (#8921)
# Description
This PR fixes the breaking changes to the reedline API due to
https://github.com/nushell/reedline/pull/562. It does not implement any
new features but just gets nushell back to compiling again.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-18 08:35:10 -05:00
JT
32f098d91d
Hopefully speedup startup (#8913)
# Description

Trying a few different things to hopefully speedup startup a bit. I'm
seeing some improvement on my box for the profiles I have, but the data
I'm seeing is noisy.

- Remove allocations in a few places where we created vec's but could
use iterators
- Pre-allocate space for blocks based on the lite block
- Removed a few extra clones

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-18 20:19:08 +12:00
Bob Hyman
f82a1d8e4e
Replace #8824: CONTRIBUTING.md for standard library (#8894)
# 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.
-->

Replaces #8824, which was languishing in review limbo and becoming
increasingly difficult to keep current with upstream changes.

In addition to all the edits, this PR includes updated documentation for
running unit tests via `std run-tests`.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
A CONTRIBUTING.md documenting guidelines and getting started info for
potential stdlib contributors.
# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-17 19:13:50 +02:00
Darren Schroeder
f0e0ab35fc
allow custom commands to show up in $nu.scope.commands better (#8910)
# Description
This PR allows our custom commands to show up in `$nu.scope.commands`
better. It still needs work because this PR hard code the input and
output types as `Type::Any` but the reason they're being missed in the
first place is that they are not assigned an input and output type.

This allows things like this now. Note the `where is_custom == true` 

![image](https://user-images.githubusercontent.com/343840/232523925-97eeef78-9722-4184-b60f-9d06f994c8e3.png)

Another example.

![image](https://user-images.githubusercontent.com/343840/232525706-d4d088d8-6597-43ba-97c8-ab03c2c7408c.png)

![image](https://user-images.githubusercontent.com/343840/232525797-b7e9ded3-b299-489e-af33-7390f4291bfd.png)


# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-17 11:19:37 -05:00
Darren Schroeder
3b20d6890c
remove debug print bug (#8909)
# Description
Oops. Someone just found a eprintln that I left in the code 3 weeks ago.
This removes that debug message.
2023-04-17 14:47:08 +02:00
Vaishaag Subhagan
6eb00f6c60
Fix strange error on unbalanced curly braces (#8906)
# Description

Fixes issue https://github.com/nushell/nushell/issues/8400 

# User-Facing Changes

Before

![image](https://user-images.githubusercontent.com/5063945/232443913-a8fe9f50-2014-4edd-95b0-516058566f64.png)

After

![image](https://user-images.githubusercontent.com/5063945/232444266-375d9438-0688-4f49-a884-b8650110f7fe.png)
2023-04-17 21:51:10 +12:00
Reilly Wood
4ecec59224
Upgrade open crate to fix WSL bug (#8905)
This PR upgrades the [`open`](https://github.com/Byron/open-rs) crate
(used in the `start` command) from 4.0.1 to 4.0.2. This fixes a bug
where `open` doesn't always work properly on WSL:
https://github.com/Byron/open-rs/pull/71
2023-04-16 22:05:40 -07:00
JT
bf3bb66c3e
Allocate less when doing a capture discovery (#8903)
# Description

This should be a little more efficient when running the algorithm to
find the captured variables.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
-->
2023-04-17 10:24:56 +12:00
WindSoilder
cbedc8403f
update command: make $in(in closure body) takes cell path (#8610)
# Description

Make `$in` takes cell path in `update` command

The reason behind the change:
https://discord.com/channels/601130461678272522/615329862395101194/1088405671080370196
> when i use update on some cell path, it's almost always because i want
to start with its previous value and change it.

cc @amtoine 

# User-Facing Changes

## Before
```
open Cargo.toml | get package | update metadata.binstall.pkg-fmt {|| $in.metadata.binstall.pkg-fmt | str replace "g" "FOO"}
```

## After
```
open Cargo.toml | get package | update metadata.binstall.pkg-fmt {|| str replace "g" "FOO"}
```

If use want to access original raw, it can be accessed by parameters in
closure:
```
open Cargo.toml | get package | update metadata.binstall.pkg-fmt {|$it| $it.metadata.binstall.pkg-fmt | str replace "g" "FOO"}
```
For this reason, I don't think we need to add a flag like `--whole`

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-04-15 10:26:21 +02:00
Maria José Solano
1d68c48a92
Allow arguments for the last flag in short flag batch (#8808)
# Description
_Fixes #5923_

Currently `nushell` doesn't allow short flag batches to contain
arguments, despite this being a common pattern in commands like `git
commit -am 'My commit message'`. This PR relaxes this so that the last
flag in the batch can take an argument.

# User-Facing Changes
- `nu::parser::short_flag_arg_cant_take_arg` has been replaced by
`nu::parser::only_last_flag_in_batch_can_take_arg` and is displayed when
a flag other then the last in a short flag batch takes an argument.

# Tests + Formatting
- Both
[`test_parser.rs`](48af0ebc3c/crates/nu-parser/tests/test_parser.rs (L640-L704))
and
[`test_known_external.rs`](48af0ebc3c/src/tests/test_known_external.rs (L42-L61))
have been updated to test the new allowed and disallowed scenarios.

---------

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-04-15 10:24:51 +02:00
Amirhossein Akhlaghpour
fff4de5c44
Apply continue to each (#8889)
# Description
Fixes #8878
Add continue command on each and added new tests too .
2023-04-15 17:11:02 +12:00
goldfish
45d33e70db
Change NU_LIB_DIRS not to depend on $nu.config-path (#8887) 2023-04-14 23:16:00 +03:00
WindSoilder
9b35d59023
Update crossterm version to 0.26 (#8623)
# Description

This pr is a companion to https://github.com/nushell/reedline/pull/560

Fortunally, we don't need to change too much nushell code.

## Additional note about lscolor dependency
https://github.com/sharkdp/lscolors/pull/58~~
lscolor is using 0.26 for now
2023-04-14 22:14:57 +02:00
Sygmei
71611dec4f
feat: added items command for Records (#8640)
# Description

This PR adds an `items` command which allows the user to iterate over
both `columns` and `values` of a `Record<>` type at the same time.


![image](https://user-images.githubusercontent.com/3835355/227976277-c9badbb2-2e31-4243-8d00-7e28f2289587.png)

# User-Facing Changes

No breaking changes, only a new `items` command.

# Formatting

- `cargo fmt --all -- --check` 👌 
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` 👌
- `cargo test --workspace` 👌
2023-04-14 14:42:33 -05:00
mike
a122e55129
use let-else syntax where possible (#8886)
# Description
this pr changes some `if-let`s to `let-else`s

# User-Facing Changes
none
2023-04-14 20:51:38 +02:00
Stefan Holderbach
6cedc05384
Fix span of multibyte short flags (#8866)
# Description

Follow up to #8849

Work for #8821
Should unblock work on #8808

Missing is a restriction to printables or identifiers according to
[UAX31](https://www.unicode.org/reports/tr31/)

# User-Facing Changes

Non ASCII characters should be allowed in shortflags.

# Tests + Formatting

Want to add some tests for the error reporting cases
2023-04-14 18:53:14 +02:00
Bob Hyman
8efbb48cb0
Pick up fix in dtparse for nanosec truncation noted at bottom of #8337 (#8805)
# Description

Pick up [enhancement in
`dtparse`](https://github.com/bspeice/dtparse/pull/41), to preserve
nanoseconds in string-to-date conversions.

# User-Facing Changes

An especially eagle-eyed user might notice that prior versions of
nushell were losing nanosecond precision when converting string format
date/time to datetime.

Before:
```nushell
〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record
╭────────────┬───────────╮
│ year       │ 2023      │
│ month      │ 3         │
│ day        │ 2         │
│ hour       │ 1         │
│ minute     │ 2         │
│ second     │ 3         │
│ nanosecond │ 987654000 │
│ timezone   │ -04:00    │
╰────────────┴───────────╯
```
Now, it just works(tm)
```nushell
〉'2023-03-02T01:02:03.987654321' | into datetime | date to-record
╭────────────┬───────────╮
│ year       │ 2023      │
│ month      │ 3         │
│ day        │ 2         │
│ hour       │ 1         │
│ minute     │ 2         │
│ second     │ 3         │
│ nanosecond │ 987654321 │
│ timezone   │ -04:00    │
╰────────────┴───────────╯
```

# Tests + Formatting

Don't forget to add tests that cover your changes.

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

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass  
Some (unrelated) tests did fail [^err]
- [x] `cargo run -- crates/nu-std/tests.nu` 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.

# (Unrelated) test failures noted
[^err]: Several tests are failing, unrelated to this PR

```
failures:

---- modules::module_import_env_1 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env main.nu; use main.nu foo; foo
   ·            ───┬───
   ·               ╰── file not found
   ╰────


thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"foo"`', tests/modules/mod.rs:316:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- modules::module_import_env_2 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env main.nu; $env.FOO
   ·            ───┬───
   ·               ╰── file not found
   ╰────


thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"foo"`', tests/modules/mod.rs:341:9

---- overlays::overlay_use_do_cd_file_relative stdout ----
=== stderr

thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)`
  left: `"nushell"`,
 right: `"test1"`', tests/overlays/mod.rs:919:9

---- overlays::overlay_use_dont_cd_overlay stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename
   ·            ─────────┬─────────
   ·                     ╰── file not found
   ╰────


thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9

---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env lol/lol.nu; $env.FOO
   ·            ─────┬────
   ·                 ╰── file not found
   ╰────


thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"good"`', tests/parsing/mod.rs:177:9

---- parsing::parse_file_relative_to_parsed_file_simple stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env lol/lol/lol.nu; $env.LOL
   ·            ───────┬──────
   ·                   ╰── file not found
   ╰────


thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"lol"`', tests/parsing/mod.rs:99:9

---- shell::const_nu_lib_dirs_relative stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[main.nu:1:1]
 1 │ const NU_LIB_DIRS = [ 'scripts' ]
 2 │ source-env foo.nu
   ·            ───┬──

thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9

---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ----
=== stderr

thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13

---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ----
=== stderr

thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13


failures:
    modules::module_import_env_1
    modules::module_import_env_2
    overlays::overlay_use_do_cd_file_relative
    overlays::overlay_use_dont_cd_overlay
    parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1
    parsing::parse_file_relative_to_parsed_file_simple
    shell::const_nu_lib_dirs_relative
    shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines
    shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings

test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s

error: test failed, to rerun pass `-p nu --test main`

failures:

---- modules::module_import_env_1 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env main.nu; use main.nu foo; foo
   ·            ───┬───
   ·               ╰── file not found
   ╰────


thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"foo"`', tests/modules/mod.rs:316:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- modules::module_import_env_2 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env main.nu; $env.FOO
   ·            ───┬───
   ·               ╰── file not found
   ╰────


thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"foo"`', tests/modules/mod.rs:341:9

---- overlays::overlay_use_do_cd_file_relative stdout ----
=== stderr

thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)`
  left: `"nushell"`,
 right: `"test1"`', tests/overlays/mod.rs:919:9

---- overlays::overlay_use_dont_cd_overlay stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename
   ·            ─────────┬─────────
   ·                     ╰── file not found
   ╰────


thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9

---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env lol/lol.nu; $env.FOO
   ·            ─────┬────
   ·                 ╰── file not found
   ╰────


thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"good"`', tests/parsing/mod.rs:177:9

---- parsing::parse_file_relative_to_parsed_file_simple stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env lol/lol/lol.nu; $env.LOL
   ·            ───────┬──────
   ·                   ╰── file not found
   ╰────


thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"lol"`', tests/parsing/mod.rs:99:9

---- shell::const_nu_lib_dirs_relative stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[main.nu:1:1]
 1 │ const NU_LIB_DIRS = [ 'scripts' ]
 2 │ source-env foo.nu
   ·            ───┬──

thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9

---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ----
=== stderr

thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13

---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ----
=== stderr

thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13


failures:
    modules::module_import_env_1
    modules::module_import_env_2
    overlays::overlay_use_do_cd_file_relative
    overlays::overlay_use_dont_cd_overlay
    parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1
    parsing::parse_file_relative_to_parsed_file_simple
    shell::const_nu_lib_dirs_relative
    shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines
    shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings

test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s

error: test failed, to rerun pass `-p nu --test main`
failures:

---- modules::module_import_env_1 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env main.nu; use main.nu foo; foo
   ·            ───┬───
   ·               ╰── file not found
   ╰────


thread 'modules::module_import_env_1' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"foo"`', tests/modules/mod.rs:316:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- modules::module_import_env_2 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env main.nu; $env.FOO
   ·            ───┬───
   ·               ╰── file not found
   ╰────


thread 'modules::module_import_env_2' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"foo"`', tests/modules/mod.rs:341:9

---- overlays::overlay_use_do_cd_file_relative stdout ----
=== stderr

thread 'overlays::overlay_use_do_cd_file_relative' panicked at 'assertion failed: `(left == right)`
  left: `"nushell"`,
 right: `"test1"`', tests/overlays/mod.rs:919:9

---- overlays::overlay_use_dont_cd_overlay stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env test1/test2/spam.nu; $env.PWD | path basename
   ·            ─────────┬─────────
   ·                     ╰── file not found
   ╰────


thread 'overlays::overlay_use_dont_cd_overlay' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"overlay_use_dont_cd_overlay"`', tests/overlays/mod.rs:946:9

---- parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1 stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env lol/lol.nu; $env.FOO
   ·            ─────┬────
   ·                 ╰── file not found
   ╰────


thread 'parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"good"`', tests/parsing/mod.rs:177:9

---- parsing::parse_file_relative_to_parsed_file_simple stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[source:1:1]
 1 │ source-env lol/lol/lol.nu; $env.LOL
   ·            ───────┬──────
   ·                   ╰── file not found
   ╰────


thread 'parsing::parse_file_relative_to_parsed_file_simple' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"lol"`', tests/parsing/mod.rs:99:9

---- shell::const_nu_lib_dirs_relative stdout ----
=== stderr
Error: nu:🐚:file_not_found

  × File not found
   ╭─[main.nu:1:1]
 1 │ const NU_LIB_DIRS = [ 'scripts' ]
 2 │ source-env foo.nu
   ·            ───┬──

thread 'shell::const_nu_lib_dirs_relative' panicked at 'assertion failed: outcome.err.is_empty()', tests/shell/mod.rs:166:9

---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines stdout ----
=== stderr

thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"AndrásWithKitKat"`', tests/shell/pipeline/commands/external.rs:198:13

---- shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings stdout ----
=== stderr

thread 'shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings' panicked at 'assertion failed: `(left == right)`
  left: `""`,
 right: `"jt_likes_cake.txt"`', tests/shell/pipeline/commands/external.rs:173:13


failures:
    modules::module_import_env_1
    modules::module_import_env_2
    overlays::overlay_use_do_cd_file_relative
    overlays::overlay_use_dont_cd_overlay
    parsing::parse_file_relative_to_parsed_file_dont_use_cwd_1
    parsing::parse_file_relative_to_parsed_file_simple
    shell::const_nu_lib_dirs_relative
    shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_lines
    shell::pipeline::commands::external::it_evaluation::takes_rows_of_nu_value_strings

test result: FAILED. 386 passed; 9 failed; 20 ignored; 0 measured; 0 filtered out; finished in 98.06s

error: test failed, to rerun pass `-p nu --test main`
```
2023-04-14 07:24:46 -05:00
Máté FARKAS
0bfa769b7d
std: remove logging example (#8877)
The example is is going to be included in the documentation, so I think
we no longer need it here.
See: https://github.com/nushell/nushell.github.io/pull/870
2023-04-14 07:15:56 -05:00
dependabot[bot]
5afc49250f
Bump umask from 2.0.0 to 2.1.0 (#8835) 2023-04-14 12:15:22 +00:00
dependabot[bot]
efb81a1277
Bump winreg from 0.11.0 to 0.50.0 (#8837) 2023-04-14 12:15:01 +00:00
Jelle Besseling
8ddebcb932
Add $env.CURRENT_FILE variable (#8861)
Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-04-13 23:33:29 +03:00
Máté FARKAS
b2d7427d2d
Move unit test runner to standard library (#8850)
Move test runner to standard library.
Originated from #8819 

# After Submitting

I'll update the documentation about testing:
http://www.nushell.sh/book/testing.html

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-04-13 21:46:37 +02:00
dependabot[bot]
b4400c4896
Bump rstest from 0.16.0 to 0.17.0 (#8836) 2023-04-13 18:58:37 +00:00
dependabot[bot]
5a8d4c628f
Bump sys-locale from 0.2.4 to 0.3.0 (#8838) 2023-04-13 18:57:25 +00:00
Vaishaag Subhagan
3603610026
Correct error description for unknown external commands (#8868)
# Description
Fixes issue https://github.com/nushell/nushell/issues/8643 

# User-Facing Changes

Before
<img width="442" alt="image"
src="https://user-images.githubusercontent.com/5063945/231624884-49a1ce4e-598d-4d19-882d-c22d168e6a5a.png">

After
<img width="449" alt="image"
src="https://user-images.githubusercontent.com/5063945/231625076-5f1becd7-7477-4d2f-b765-3956210da7f2.png">
2023-04-13 19:33:05 +02:00
WindSoilder
017151dff1
optimize hash md5 for binary input (#8860)
# Description

Fixes: #8260

# User-Facing Changes

`open bigfile | hash md5` no longer consumes too much memory

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-13 19:29:06 +02:00
WindSoilder
ad90b6e5f3
rm: enable trash flag on android and ios platrofm (#8871)
# Description

As title, enable trash flag on all platforms make `rm` more portable
across different platforms, but `-t` will do nothing.

Fixes: #8104

# User-Facing Changes
Na

# Tests + Formatting
It's hard to add tests because we don't run tests for android and ios
platforms.

# 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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-04-13 07:34:52 -05:00
Antoine Stevan
36036d9308
FEATURE: do not use theme-independant colors in the default configs (#8855)
# Description
i was playing with my theme a bit and i was thinking about the following
- the default themes should not use precise colors
- the default themes should let the terminal set the exact colors

for instance, the `filesize` field of the `$env.config.color_config`
looks good but not with terminal themes like dracula or tokyonight
😮

in this PR, i just use "built-in" colors, like `red` or `yellow_bold` or
`{fg: green attr: n}` to let the terminal theme set the colors 😋

# User-Facing Changes
i tried to stay as close as the previous default themes, so there should
be the least amount of differences 😌

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-04-12 17:09:44 -05:00
JT
487789b45b
Adds multi-file support to IDE support (#8857)
# Description

This adds multi-file support to the in-progress IDE support. The main
new features are a `-I` flag that allows you to add a new source search
path when starting up the nu binary, and fixes for the current IDE
support to support spans in other files.

This needs accompanying fixes to the vscode/lsp implementation to pass
along the project directory via `-I`.

UPDATE: Marking this draft until we have a means to test 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-13 05:36:29 +12:00
JT
8ee52b6ee1
Relax the closure syntax, highlight differently (#8846)
# Description

This relaxes the closure syntax so that `||` is no longer required. This
allows for `ls | each { $in.name }` for example.

I've gone ahead and changed the syntax highlighting so that blocks and
closures are distinct for now.

# User-Facing Changes

Removes `||` requirement for closures.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-12 05:21:52 +12:00
JT
46dba8853a
Revert numberlike parsing restriction (#8845)
# Description

This effectively reverts #8635. We shipped this change with 0.78 and
received many comments/issues related to this restriction feeling like a
step backward.

fixes: #8844 
(and probably other issues)

# User-Facing Changes

Returns numbers and number-like values to being allowed to be bare
words. Examples: `3*`, `1fb43`, `4,5`, and related.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-12 05:21:31 +12:00
federico viscomi
eb4d19fb9c
Parser panic for signature with multibyte char for short flag #8821 (#8849)
Hey I'm a developer and I'm still new to nushell and rust but I would
like to learn more about both. This is my first PR for this project.

The intent of my change is to allow to use multibyte utf-8 characters in
commands short flags.
2023-04-11 09:52:51 +12:00
Máté FARKAS
c3678764b4
stdlib test runner: implement setup and teardown commands to unit tests (#8776)
# Description

As in other testing frameworks, the `setup` runs before every test case,
and the `teardown` after that. A context can be created in `setup`,
which will be in the `$in` variable in the test cases, and in the
`teardown`. The `teardown` is called regardless of the test is passed,
skipped, or failed.

For example:

```nushell
use std.nu *

export def setup [] {
    log debug "Setup is running"
    {msg: "This is the context"}
}

export def teardown [] {
    log debug $"Teardown is running. Context: ($in)"
}

export def test_assert_pass [] {
    log debug $"Assert is running. Context: ($in)"
}

export def test_assert_skip [] {
    log debug $"Assert is running. Context: ($in)"
    assert skip
}

export def test_assert_fail_skipped_by_default [] {
    log debug $"Assert is running. Context: ($in)"
    assert false
}
```


![image](https://user-images.githubusercontent.com/282320/230466359-9908cc72-edbd-4150-9aff-d15fe42c0cc7.png)

# After Submitting

I'll update the documentation.

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-04-10 22:42:11 +02:00
nibon7
74dcac3b0d
Fix process_range on 32-bit platforms (#8842)
# Description

This PR fixes
`commands::str_::substrings_the_input_and_treats_end_index_as_length_if_blank_end_index_given`
testcase on 32-bit platform.

```
failures:
---- commands::str_::substrings_the_input_and_treats_end_index_as_length_if_blank_end_index_given stdout ----
=== stderr
thread 'commands::str_::substrings_the_input_and_treats_end_index_as_length_if_blank_end_index_given' panicked at 'assertion failed: `(left == right)`
  left: `"arepa"`,
 right: `"arepas"`', crates/nu-command/tests/commands/str_/mod.rs:363:9
failures:
    commands::str_::substrings_the_input_and_treats_end_index_as_length_if_blank_end_index_given
test result: FAILED. 1072 passed; 1 failed; 23 ignored; 0 measured; 0 filtered out; finished in 2.98s
error: test failed, to rerun pass `-p nu-command --test main`
```

https://gitlab.alpinelinux.org/nibon7/aports/-/jobs/1005935#L3864
https://gitlab.alpinelinux.org/nibon7/aports/-/jobs/1005931#L3867

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-11 06:52:42 +12:00
Antoine Stevan
6d51e34d0a
stdlib: make helper modules available in std (#8841)
> **Note**
> waiting for the following to land
> - https://github.com/nushell/nushell/pull/8824 to avoid conflicts,
i'll add this to `CONTRIBUTING.md` once it's ready 👍

should close #8839 

# Description
this PR moves the `log` submodule of `std` to the top of the call stack,
making it available in the rest of the library as `log`.
i've added some comments around the `submodules` list in
`load_standard_library` to make it clear how it should work.
 
# User-Facing Changes
`log` and `assert` are now available in the rest of `std`.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-10 13:32:33 -05:00
WindSoilder
de76c7a57d
Remove autoprinting of for loop (#8843)
# Description

It's an addition to https://github.com/nushell/nushell/pull/8618
And I think it's good to keep the same behavior when we use for loop for
list.

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-11 05:23:22 +12:00
Stefan Holderbach
0e23400510
Follow up #8758 with a style fix (#8822)
# Description

The old comment around the question mark operator doesn't make sense
 to me based on the closure signature.
The `match` expressions were thus superfluous.


# User-Facing Changes

None

# Tests + Formatting

No change
2023-04-09 18:42:43 -07:00
Antoine Stevan
d0a83fec69
stdlib: add completion to help commands (#8799)
> **Note**
> waiting for
> - https://github.com/nushell/nushell/pull/8770
> - #8815

# Description
this PR adds a very basic completion support to the `help`
implementations of the `std`.

# User-Facing Changes
completion on all the `std help ...` commands, based on the names in
`$nu.scope.`

# Tests + Formatting
-  `toolkit fmt`
-  `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-10 10:59:57 +12:00
Stefan Holderbach
57510f2fd2
Move CLI related commands to nu-cli (#8832)
# Description

Part of the larger cratification effort.

Moves all `reedline` or shell line editor specific commands to `nu-cli`.

## From `nu-cmd-lang`:
- `commandline`
- This shouldn't have moved there. Doesn't directly depend on reedline
but assumes parts in the engine state that are specific to the use of
reedline or a REPL

## From `nu-command`:
- `keybindings` and subcommands
  - `keybindings default`
  - `keybindings list`
  - `keybindings listen`
    - very `reedline` specific
- `history`
  - needs `reedline`
- `history session`

## internal use
Instead of having a separate `create_default_context()` that calls
`nu-command`'s `create_default_context()`, I added a `add_cli_context()`
that updates an `EngineState`


# User-Facing Changes

None

## Build time comparison

`cargo build --timings` from a `cargo clean --profile dev`

### total
main: 64 secs
this: 59 secs

### `nu-command` build time

branch | total| codegen | fraction  
---|---|---|---
main | 14.0s | 6.2s | (44%)
this | 12.5s | 5.5s | (44%)

`nu-cli` depends on `nu-command` at the moment.
Thus it is built during the code-gen phase of `nu-command` (on 16
virtual cores)

# Tests + Formatting

I removed the `test_example()` facilities for now as we had not run any
of the commands in an `Example` test and importing the right context for
those tests seemed more of a hassle than the duplicated
`test_examples()` implementations in `nu-cmd-lang` and `nu-command`
2023-04-10 10:56:47 +12:00
JT
58b96fdede
Add option to not load std-lib. Default tests to not use std-lib (#8833)
this adds a `--no-std-lib` flag. Moves `nu!` to use the `--no-std-lib`.
Adds a new `nu_with_std!` macro for future tests that need the std-lib.

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

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-10 10:55:29 +12:00
JT
9e3d6c3bfd
Only add the std lib files once (#8830)
# Description

We were seeing duplicate entries for the std lib files, and this PR
addresses that. Each file should now only be added once.

Note: they are still parsed twice because it's hard to recover the
module from the output of `parse` but a bit of clever hacking in a
future PR might be able to do that.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` 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.
2023-04-10 08:55:47 +12:00
Antoine Stevan
4a955d7e76
stdlib: refactor into a multi-module library (#8815) 2023-04-09 20:00:20 +03:00
mike
637283ffad
allow register to accept a const argument (#8758)
# Description

this pr allows `register` to be used with const variables
```nu
const math_plugin = "~/.config/nushell/plugins/nu_plugin_math"
register $math_plugin
```

should close #8208, previous work #8435
2023-04-08 15:04:57 -05:00
Antoine Stevan
d128c0e02b
stdlib: use the loaded library in tests and update README (#8811)
Should close #8809.

# Description
this PR uses the automatically loaded library from the tests by
replacing `use std.nu ...` with `use std ...`.

the `README` has been updated by
- removing the very deprencated "concrete examples"
- fixing the `use std` and the "run the tests" sections

the `README` can be previewed
[here](https://github.com/amtoine/nushell/blob/refactor/stdlib/use-std-in-tests-and-update-readme/crates/nu-std/README.md)
👍

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-08 07:35:16 -05:00
Michael Angerman
60e6ea5abd
remove nu_cli crate dependency from nu_std (#8807)
now nu_std only depends on nu_parser, nu_protocol and miette
and removes the nu_cli dependency

this enables developers moving forward to come along and implement their
own CLI's without having to pull in a redundant nu-cli which will not be
needed for them.

I did this by moving report_error into nu_protocol
which nu_std already has a dependency on anyway....



- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests.nu` 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
> ```
2023-04-08 13:53:43 +02:00
Antoine Stevan
415607706f
remove the "MODULE NOT FOUND" print from the parser (#8816)
related to #8765.
should close #8812.

# Description
this PR simply removes the `prinln("MODULE NOT FOUND")` from the parser.

# User-Facing Changes
no more `MODULE NOT FOUND` while typing a `use` command
2023-04-08 13:19:09 +02:00
JT
f2b977b9c5
improve operation mismatch errors (#8800)
# Description

This improves the operation mismatch error in a few ways:

* We now detect if the left-hand side of the operation is at fault, and
show a simpler error/error message if it is
* Removed the unhelpful hint
* Updated the error text to make it clear what types are causing the
issue


![image](https://user-images.githubusercontent.com/547158/230666329-537a8cae-6350-4ee7-878e-777e05c4f265.png)


![image](https://user-images.githubusercontent.com/547158/230666353-93529dc2-039a-4774-a84c-a6faac94d8e2.png)


# User-Facing Changes

Error texts and spans will change

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-04-08 09:32:44 +12:00
Harshal Chaudhari
35e8420780
fix(nu-command/tests): further remove unnecessary pipeline() and cwd() (#8793)
# Description

This PR further fixes tests as part of #8670 

# User-Facing Changes

None

# Tests + Formatting

None

# After Submitting

None

---------

Signed-off-by: Harshal Chaudhari <harshal.chaudhary@gmail.com>
Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
2023-04-07 14:09:55 -07:00
Michael Angerman
5ec6edb9c5
add LICENSE to nu-std (#8803)
# 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.)_

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests.nu` 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.
2023-04-07 13:39:21 -07:00
Antoine Stevan
5d8bedfbe4
stdlib: make the library a standalone crate (#8770)
# Description
as we now have a prelude thanks to #8627, i'd like to work on the
structure of the library 😋

and i think the first step is to make it a true standalone crate 😏

this PR
- moves all the library from `crates/nu-utils/standard_library/` to
`crates/nu-std/`
- moves the `rust` loading code from `src/run.rs` to
`crates/nu-std/src/lib.rs`
2023-04-07 22:12:27 +02:00
JT
0477493734
Fix parser recovery after error (#8798)
# Description

This fixes the parser recovery after the first error (at least the main
culprit), where `parse_value` was not able to properly parse `any`
values after the first error.

fixes #8796 

# User-Facing Changes

None

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-04-08 07:01:12 +12:00
Jelle Besseling
e6b196c141
Add $nu.current-exe variable (#8789)
# Description

Part solving #8752

Adds an extra variable to the `nu` table `current-exe` which is the path
to the running shell executable.

# User-Facing Changes

Adds a variable to the `nu` table.

# Tests + Formatting

Tests and formatting have been run. No new test added

# After Submitting

I could add documentation for this if wanted

Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-04-07 13:51:09 -05:00
Antoine Stevan
49960beb35
FEATURE: make the link in the ansi extra usage an ANSI link (#8795)
# Description
this addresses the comments of @fdncred from
https://github.com/nushell/nushell/issues/8713#issuecomment-1498206087

the exact ANSI link has been generated with
```bash
"https://en.wikipedia.org/wiki/ANSI_escape_code" | ansi link --text "ANSI escape code" | debug -r
```

# User-Facing Changes
there is now an ANSI link in the `ansi` help page instead of a markdown
link.

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-04-07 13:39:51 -05:00
Jakub Žádník
1b677f167e
Remove old alias implementation (#8797) 2023-04-07 21:09:38 +03:00
goldfish
a3ea0c304a
Fix config {nu,env} to open $nu.{config,env}-file (#8792)
# Description

fixed #8755
Now, command `config {nu,env}` opens default file
`.config/nushell/{config,env}.nu`.
This behavior is inappropriate when `nu` is launched with option
`--config` or `--env-config`.
This PR changes the file that the command opens to
`$nu.{config,env}-file`.

# User-Facing Changes

`config {nu,env}` opens `$nu.{config,env}-file`.
2023-04-07 18:37:54 +02:00
WMR
4fda6d7eaa
Add regex separators for split row/list/column (#8707)
# Description

Verified on discord with maintainer

Change adds regex separators in split rows/column/list. The primary
motivating reason was to make it easier to split on separators with
unbounded whitespace without requiring a lot of trim jiggery. But,
secondary motivation is the same as the set of all motivations for
adding split regex features to most languages.

# User-Facing Changes

Adds -r option to split rows/column/list.

# Tests + Formatting

Ran tests, however tests.nu fails with unrelated errors:

```
~/src/nushell> cargo run -- crates/nu-utils/standard_library/tests.nu                                                                                                                                                          04/02/2023 02:07:25 AM
    Finished dev [unoptimized + debuginfo] target(s) in 0.24s
     Running `target/debug/nu crates/nu-utils/standard_library/tests.nu`
INF|2023-04-02T02:07:27.060|Running tests in test_asserts
INF|2023-04-02T02:07:27.141|Running tests in test_dirs
Error:
  × list is just pwd after initialization

INF|2023-04-02T02:07:27.167|Running tests in test_logger
INF|2023-04-02T02:07:27.286|Running tests in test_std
Error:
  × some tests did not pass (see complete errors above):
  │
  │       test_asserts test_assert
  │       test_asserts test_assert_equal
  │       test_asserts test_assert_error
  │       test_asserts test_assert_greater
  │       test_asserts test_assert_greater_or_equal
  │       test_asserts test_assert_length
  │       test_asserts test_assert_less
  │       test_asserts test_assert_less_or_equal
  │       test_asserts test_assert_not_equal
  │     ⨯ test_dirs test_dirs_command
  │       test_logger test_critical
  │       test_logger test_debug
  │       test_logger test_error
  │       test_logger test_info
  │       test_logger test_warning
  │       test_std test_path_add
  │
```

Upon investigating seeing this difference:

```
╭───┬─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 0 │ /var/folders/1f/ltbr1m8s5s1811k6n1rhpc0r0000gn/T/test_dirs_c1ed89d6-19f7-47c7-9e1f-74c39f3623b5         │
│ 1 │ /private/var/folders/1f/ltbr1m8s5s1811k6n1rhpc0r0000gn/T/test_dirs_c1ed89d6-19f7-47c7-9e1f-74c39f3623b5 │
╰───┴─────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```

This seems unrelated to my changes, but can investigate further if
desired.

# 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: Robert Waugh <robert@waugh.io>
2023-04-07 06:46:11 -05:00
Bob Hyman
771e24913d
range operator accepts bot..=top as well as bot..top (#8382)
# Description

A compromise fix for #8162. Nushell range operator now accepts `..=` to
mean the range includes the top value, so you can use your Rust habits.
But the unadorned `..` range operator also includes the value, so you
can also use your Nushell habits.

_(Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.)_

```nushell
〉1..5
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
│ 3 │ 4 │
│ 4 │ 5 │
╰───┴───╯
-------------------------------------------- /home/bobhy/src/rust/nushell --------------------------------------------
〉1..=5
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
│ 3 │ 4 │
│ 4 │ 5 │
╰───┴───╯
-------------------------------------------- /home/bobhy/src/rust/nushell --------------------------------------------
〉1..<5
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
│ 3 │ 4 │
╰───┴───╯
```
# User-Facing Changes

Existing scripts with range operator will continue to operate as
heretofore.

_(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:

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass

# After Submitting

Will update the book to include new syntax.
2023-04-07 06:40:05 -05:00
JT
aded2c1937
Refactor to support multiple parse errors (#8765)
# Description

This is a pretty heavy refactor of the parser to support multiple parser
errors. It has a few issues we should address before landing:

- [x] In some cases, error quality has gotten worse `1 / "bob"` for
example
- [x] if/else isn't currently parsing correctly
- probably others

# User-Facing Changes

This may have error quality degradation as we adjust to the new error
reporting mechanism.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-04-07 12:35:45 +12:00
Jakub Žádník
e54b867e8e
Remove parser keywords label from commands that do not need it (#8780) 2023-04-07 01:12:21 +03:00
Jakub Žádník
c12b4b4af7
Aliasing math expression shows error earlier (#8779) 2023-04-07 00:40:53 +03:00
Jakub Žádník
87ddba0193
Allow multi-word aliases (#8777) 2023-04-07 00:05:09 +03:00
dependabot[bot]
a29b61bd4f
Bump miette from 5.6.0 to 5.7.0 (#8720) 2023-04-06 20:39:54 +00:00
Antoine Stevan
d06ebb1686
standard library: implement help commands with $nu (#8505) 2023-04-06 22:13:22 +03:00
Máté FARKAS
74283c3ebc
stdlib: add assert skip command to skip test case (#8748) 2023-04-06 13:03:10 -05:00
Jelle Besseling
8a030f3bfc
Add ppid example for ps (#8768)
# Description

Add an extra example for the `ps` command

# User-Facing Changes

Only adds this example:


![image](https://user-images.githubusercontent.com/1576660/230374829-dc957b89-0a76-451d-baba-5e4463b150c3.png)

# Tests + Formatting

N/A

# After Submitting

This is related to https://github.com/nushell/nushell.github.io/pull/864

Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-04-06 07:32:12 -05:00
Máté FARKAS
5518ffd248
Stdlib: use default color for info log level (#8766)
To make it work with a light theme, as well. The dark theme is not
affected, since the default color is white there.

## Before


![image](https://user-images.githubusercontent.com/282320/230329663-6fae7b7d-7062-459c-ad80-8da3a243d606.png)

## After


![image](https://user-images.githubusercontent.com/282320/230329784-c40bf93e-0740-4b87-ae19-84fd7983898a.png)

Also, I added back the example command to the test script which is very
useful in these cases...

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-04-06 06:45:45 -05:00
Jan9103
bcdb9bf5b4
Update some help examples (#8759)
# 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.)_
-->

Recently a few things changed, which now create issues:
- `1.0.0`, `+500`, and `0x000000` used to get parsed as string, but now
just errors
- `each { print $in }` -> `each {|| print $in }`

I looked through all the help pages and fixed every highlighted (red
background) error: `help commands | each {|i| help $i.name} | table |
less`

# User-Facing Changes

<!--
_(List of all changes that impact the user experience here. This helps
us keep track of breaking changes.)_
-->

The examples work again and no longer contain error syntax-highlighting

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
-->
2023-04-05 18:36:00 -05:00
dependabot[bot]
3509bde1a9
Bump windows from 0.46.0 to 0.48.0 (#8721)
Bumps [windows](https://github.com/microsoft/windows-rs) from 0.46.0 to
0.48.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/microsoft/windows-rs/releases">windows's
releases</a>.</em></p>
<blockquote>
<h2>0.48.0</h2>
<p>This release includes an update to all crates to address a target
version reliability issue. This issue is detailed here: <a
href="https://redirect.github.com/microsoft/windows-rs/issues/2410#issuecomment-1490802715">microsoft/windows-rs#2410</a></p>
<h2>What's Changed</h2>
<ul>
<li>Improve target version reliability by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2412">microsoft/windows-rs#2412</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/microsoft/windows-rs/compare/0.47.0...0.48.0">https://github.com/microsoft/windows-rs/compare/0.47.0...0.48.0</a></p>
<h2>0.47.0</h2>
<p>As a reminder, updates are only published by request (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2397">#2397</a>;
<a
href="https://redirect.github.com/microsoft/win32metadata/issues/1507">microsoft/win32metadata#1507</a>).
This release provides an update to the <code>windows</code> crate. It
does not include an update to the <code>windows-sys</code> crate.</p>
<p>This update adds support for standalone code generation (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2396">#2396</a>)
as well as requested fixes to the Win32 metadata that prevented some
APIs from being used.</p>
<h2>What's Changed</h2>
<ul>
<li>Workaround for <code>rustdoc</code> regression by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2381">microsoft/windows-rs#2381</a></li>
<li>Token privilege samples by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2382">microsoft/windows-rs#2382</a></li>
<li>Apply <code>const</code> parameter metadata by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2384">microsoft/windows-rs#2384</a></li>
<li>Advanced metadata filtering by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2385">microsoft/windows-rs#2385</a></li>
<li>Update Win32 metadata v46 by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2387">microsoft/windows-rs#2387</a></li>
<li>Support standalone code generation by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2396">microsoft/windows-rs#2396</a></li>
<li>Update readme to include <code>windows-targets</code> and
<code>windows-bindgen</code> by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2399">microsoft/windows-rs#2399</a></li>
<li>Update Win32 metadata v47 by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2400">microsoft/windows-rs#2400</a></li>
<li>Version 0.47.0 by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2401">microsoft/windows-rs#2401</a></li>
<li>Add CLR test for lib validation by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2403">microsoft/windows-rs#2403</a></li>
<li>Restore reproducible libs by <a
href="https://github.com/riverar"><code>@​riverar</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2402">microsoft/windows-rs#2402</a></li>
<li>Check diff for all targets by <a
href="https://github.com/kennykerr"><code>@​kennykerr</code></a> in <a
href="https://redirect.github.com/microsoft/windows-rs/pull/2404">microsoft/windows-rs#2404</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/microsoft/windows-rs/compare/0.46.0...0.47.0">https://github.com/microsoft/windows-rs/compare/0.46.0...0.47.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="406944152e"><code>4069441</code></a>
Improve target version reliability (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2412">#2412</a>)</li>
<li><a
href="ec95c1e6ac"><code>ec95c1e</code></a>
Check diff for all targets (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2404">#2404</a>)</li>
<li><a
href="91e0a5c079"><code>91e0a5c</code></a>
Restore reproducible libs (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2402">#2402</a>)</li>
<li><a
href="36ea325a8d"><code>36ea325</code></a>
Add CLR test for lib validation (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2403">#2403</a>)</li>
<li><a
href="e03d14e2d0"><code>e03d14e</code></a>
Version 0.47.0 (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2401">#2401</a>)</li>
<li><a
href="f86349d691"><code>f86349d</code></a>
Update Win32 metadata v47 (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2400">#2400</a>)</li>
<li><a
href="3e3c87b5ed"><code>3e3c87b</code></a>
Update readme to include <code>windows-targets</code> and
<code>windows-bindgen</code> (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2399">#2399</a>)</li>
<li><a
href="6672c6d28a"><code>6672c6d</code></a>
Support standalone code generation (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2396">#2396</a>)</li>
<li><a
href="f3ef2cdfa7"><code>f3ef2cd</code></a>
Update Win32 metadata v46 (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2387">#2387</a>)</li>
<li><a
href="3507dcd3b1"><code>3507dcd</code></a>
Advanced metadata filtering (<a
href="https://redirect.github.com/microsoft/windows-rs/issues/2385">#2385</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/microsoft/windows-rs/compare/0.46.0...0.48.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=windows&package-manager=cargo&previous-version=0.46.0&new-version=0.48.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 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>
2023-04-05 16:54:26 -05:00
mike
add20873d0
make str index-of -r use ranges (#8724)
# Description

final follow up to #8660 

# User-Facing Changes

**BREAKING CHANGE**
any scripts using the previous string or list syntax will **BREAK**
2023-04-05 23:22:40 +02:00
Antoine Stevan
427db0d101
FEATURE: better ansi -e error (#8709)
Should close #8704.

# Description
this PR
- makes the error thrown by things like `ansi -e {invalid: "invalid"}`
more explicit
- makes the `ansi -e` example more explicit about valid / invalid keys

# User-Facing Changes
the error
```bash
> ansi -e {invalid: "invalid"}
Error: nu:🐚:incompatible_parameters

  × Incompatible parameters.
   ╭─[entry #1:1:1]
 1 │ ansi -e {invalid: "invalid"}
   ·         ──────────┬─────────
   ·                   ╰── unknown ANSI format key: expected one of ['fg', 'bg', 'attr'], found 'invalid'
   ╰────
```

the new `ansi -e` example
```bash
  Use structured escape codes
  > let bold_blue_on_red = {  # `fg`, `bg`, `attr` are the acceptable keys, all other keys are considered invalid and will throw errors.
        fg: '#0000ff'
        bg: '#ff0000'
        attr: b
    }
    $"(ansi -e $bold_blue_on_red)Hello Nu World(ansi reset)"
  Hello Nu World
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
```
$nothing
```
2023-04-05 23:14:39 +02:00
JT
56efbd7de9
Add IDE support (#8745)
# Description

This adds a set of new flags on the `nu` binary intended for use in
IDEs. Here is the set of supported functionality so far:

* goto-def - go to the definition of a variable or custom command
* type hints - see the inferred type of variables
* check - see the errors in the document (currently only one error is
supported)
* hover - get information about the variable or custom command
* complete - get a completion list at the current position

# User-Facing Changes

No changes to the REPL experience. This only impacts the IDE scenario.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-04-06 07:34:47 +12:00
dependabot[bot]
91282d4404
Bump git2 from 0.16.1 to 0.17.0 (#8722) 2023-04-05 19:20:58 +00:00
Artemiy
f723bc6989
Std xml utils (#8437)
# Description

Add `xaccess`,`xupdate` and `xinsert` scripts to standard library. They
allow accessing and manipulating data in new xml format
https://github.com/nushell/nushell/pull/7947 with relative ease.

Access some data in nushell xml structure:

![image](https://user-images.githubusercontent.com/17511668/224785447-317359e2-1430-4dfc-9307-73f1d5e50098.png)

Update attributes of xml tags matching a path:

![image](https://user-images.githubusercontent.com/17511668/224785506-85e9aa30-b36b-43db-af1d-2f4460563124.png)


# User-Facing Changes

New commands `std xaccess`, `std xupdate` and `std xinsert`

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-04-05 13:54:08 -05:00
Antoine Stevan
22142bd4ae
add a cross platform clip command to the standard library (#8695)
Should close the associated poin in #8311

# Description
this PR adds a `clip` command to `std` which
- has error support in case the clipboard system command is not
installed
- removes any ANSI escape sequences from the input to have a clean
copied text
- can throw desktop notifications on linux in case of a long pipeline
which needs to be copied (can be disabled with `--no-notify`)
- echoes the copied data to the output of the terminal (can be disabled
with --silent)
- has examples and dependencies listed
- has "charpage" 65001 (a.k.a. utf-8) support for windows

## new additions from 9cd3c951f to
ad3e8de25b
- better OS context error support
- use of the `match` statement for scalability
- `match` the value of the `$nu.os-info.name`
- add `macOS` with `pbcopy` to the list of supported systems
- throw an error when the OS is not supported
- ~~add simple tests to make sure `clip` works on all main OSes with the
CI~~ had to be removed in 6028b98483 (see
[the failing
test](https://github.com/nushell/nushell/actions/runs/4610091544/jobs/8148126550?pr=8695#step:6:35))

# User-Facing Changes
users can now access a `clip` to copy the output of any pipeline to the
system clipboard, on any system

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-04-05 13:19:42 -05:00
Antoine Stevan
caf1432dc7
refactor the ansi help page (#8713)
# Description
i've always found the `ansi --help` extra usage hard to read and
understand...
i decided to give it a shot today, so here is what i came up 😋 

- make the extra usage structured with `nushell` tables
- make the examples clearer with variables and comments

one change that might appear strange is the following last two commits
```diff
diff --git a/crates/nu-command/src/platform/ansi/ansi_.rs b/crates/nu-command/src/platform/ansi/ansi_.rs
index 4746d27fa..ba3e597c4 100644
--- a/crates/nu-command/src/platform/ansi/ansi_.rs
+++ b/crates/nu-command/src/platform/ansi/ansi_.rs
@@ -507,10 +507,7 @@ impl Command for AnsiCommand {
 
     fn signature(&self) -> Signature {
         Signature::build("ansi")
-            .input_output_types(vec![
-                (Type::Nothing, Type::String),
-                (Type::List(Box::new(Type::String)), Type::String),
-            ])
+            .input_output_types(vec![(Type::Nothing, Type::String)])
             .optional(
                 "code",
                 SyntaxShape::Any,
```
`ansi` is never used on `list` inputs, as can be seen in the `Ansi.run`
function: `_input: PipelineData` is never used.
this broke the tests (see [this
action](https://github.com/nushell/nushell/actions/runs/4589552235/jobs/8104520078#step:4:1392))
for no real reason...

# User-Facing Changes
hopefully an easier to read `help ansi` page.

# Tests + Formatting
- 🟢 `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.
2023-04-05 13:16:36 -05:00
Jelle Besseling
65c90d5b45
Add ppid to ps command (#8750)
# Description

Adds the `ppid` field that's available on all supported platforms to the
`ps` command. This would be useful in my scripts.

# User-Facing Changes

- ps output now contains an extra column

# Tests + Formatting

Not sure if I need to add a test for this

# After Submitting

Update https://www.nushell.sh/book/quick_tour.html#quick-tour to show
the new table
2023-04-05 13:12:01 -05:00
goldfish
71b4949843
Change default config to display failed LAST_EXIT_CODE (#8735)
# Description

fixed #8655 
Change default nushell configuration file `default_env.nu` to display
LAST_EXIT_CODE in the prompt. For this change, users can quickly know
that a previous command failed.

# User-Facing Changes

This change affects only users who use the default configuration.
When a command fails, the exit code is displayed in the prompt like
these figures.
* before

![image](https://user-images.githubusercontent.com/37319612/229782830-45bc6b0d-75e4-459f-ae1d-46877f740239.png)
* after

![image](https://user-images.githubusercontent.com/37319612/229784089-e68b5d14-499b-4448-b764-e6b30ca64714.png)


# Tests + Formatting

When I ran tests, `test.nu` failed with the following error.
The error also occurs in the master branch, so it's probably unrelated
to these changes.
Do I need to address it?

* `cargo fmt --all -- --check`: passed
* `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect`: passed
* `cargo test --workspace`: passed
* `cargo run -- crates/nu-utils/standard_library/tests.nu`: ~failed~
passed
```
~/oss_dev/nushell> cargo run -- crates/nu-utils/standard_library/tests.nu
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/nu crates/nu-utils/standard_library/tests.nu`
Error: nu:🐚:external_command

  × External command failed
    ╭─[/home/hiroki/oss_dev/nushell/crates/nu-utils/standard_library/tests.nu:73:1]
 73 │         | upsert test {|module|
 74 │             nu -c $'use ($module.file) *; $nu.scope.commands | select name module_name | to nuon'
    ·             ─┬
    ·              ╰── did you mean 'du'?
 75 │             | from nuon
    ╰────
  help: No such file or directory (os error 2)
  ```

# After Submitting

nothing
2023-04-05 13:06:24 -05:00
WindSoilder
54a18991ab
Loops return external stream when external command failed. (#8646) 2023-04-05 20:38:04 +03:00
K3rnelP4n1k
1fcb98289a
Add section on removing ANSI sequences with find command (#8519)
Co-authored-by: Phreno <phreno@pop-os.localdomain>
2023-04-05 20:26:20 +03:00
Thomas Coratger
01e5ba01f6
Correction bug multiple dots mkdir and touch (#8486) 2023-04-05 20:22:56 +03:00
StevenDoesStuffs
1134c2f16c
Allow NU_LIBS_DIR and friends to be const (#8538) 2023-04-05 19:56:48 +03:00
Stefan Holderbach
d18cf19a3f
Bump to 0.78.1 development version (#8741)
# Description

either just development or hotfix
2023-04-05 13:36:10 +12:00
Stefan Holderbach
2ec2028637
Bump version to 0.78.0 (#8715)
# Description

Version bump for the `0.78.0`

Start to include the version with our `default_config.nu` and
`default_env.nu`

# Checklist

- [x] reedline
- [ ] release notes
2023-04-04 20:47:00 +02:00
Stefan Holderbach
b84a01cb1d
Pin reedline to 0.18.0 release (#8728)
# Description

see release notes:

https://github.com/nushell/reedline/releases/tag/v0.18.0
2023-04-04 00:23:08 +02:00
Stefan Holderbach
ca4d8008d4
Fix rest of license year ranges (#8727)
# Description

In theory we don't need to include the end of the year range for a
proper MIT license.
2023-04-04 09:03:29 +12:00
Stefan Holderbach
68d98fcf24
Remove unused atty dep in nu-table (#8716)
# Description

nfm
2023-04-02 20:30:36 +02:00
mike
87086262f3
make bytes at use ranges (#8710)
# Description

follow up to #8660 

# User-Facing Changes

**BREAKING CHANGE**
any scripts using the previous string or list syntax will BREAK
2023-04-03 04:28:36 +12:00
Harshal Chaudhari
3fab427383
Fix(tests/nu-command): remove unnecessary cwd() and pipeline(), etc (#8711)
# Description

This PR aims to cover the tests under nu-command as part of this issue
#8670 to clean up any unnecessary wrapping funcs like `cwd(".")` or
`pipeline()`, etc.

This PR is still WIP and opening as draft to get first impressions and
feedback on a few tests before I go on changing more.


# User-Facing Changes

None

# Tests + Formatting

None

# After Submitting

None

---------

Signed-off-by: Harshal Chaudhari <harshal.chaudhary@gmail.com>
Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
2023-04-02 08:25:05 -07:00
Stefan Holderbach
61fa826159
Fix two stable clippy lints (#8712)
# Description

Unnecessary calls to `.into_iter()`


# User-Facing Changes

None

# Tests + Formatting

Only visible on stable toolchain
2023-04-02 16:23:19 +02:00
JT
0b9fc4ff3a
give better error when a numberlike is used for strings (#8706)
# Description

Before:
```
  × Type mismatch during operation.
   ╭─[source:1:1]
 1 │               def 7zup [] {} 
   ·                   ──┬─
   ·                     ╰── expected string
   ╰────
```

Now:
```
  × Type mismatch during operation.
   ╭─[source:1:1]
 1 │               def 7zup [] {} 
   ·                   ──┬─
   ·                     ╰── expected string, found number-like value (hint: use quotes or backticks)
   ╰────
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-04-02 07:48:45 +12:00
JT
1817d5e01e
prevent redefining fields in a record (#8705)
# Description

Prevents redefining fields in a record, for example `{a: 1, a: 2}` would
now error.

fixes https://github.com/nushell/nushell/issues/8699

# User-Facing Changes

Is technically a breaking change. If you relied on this behaviour to
give you the last value, your code will now error.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-04-02 06:09:33 +12:00
Antoine Stevan
0ca0f8ec17
move the show_banner config field to the top (#8702)
Should close https://github.com/nushell/nushell/issues/8698 and similar
issues.

# Description
simply moves the `show_banner` field and its comment to the top of the
default config file.

# User-Facing Changes
this should make the setting easier to see and encourage people to
modify the line instead of adding another line before the default
`show_banner: true`, which would overwrite the setting.

# Tests + Formatting
```
$nothing
```

# After Submitting
the default banner links to
https://www.nushell.sh/book/configuration.html#remove-welcome-message,
which does not mention this issue => this will have to be updated
2023-04-01 07:30:20 -05:00
Lukáš Veškrna
6be5631477
Add math exp command (issue #8661) (#8700)
# Description
I copied the `math ln` command and replaced the relevant parts to
implement `math exp`.

# User-Facing Changes

The `math exp` command was added. Now one can do `[1, 2, 3] | math exp`
to get e to the power of these numbers.

# Tests + Formatting
I only wrote example tests, same as for `math ln`, which also does not
have special tests. I have ran into an issue with the tests but it seems
completely unrelated (see #8687)

# After Submitting

This PR was done in order to make the documentation complete, so I'm not
adding any documentation except `math ln`.
2023-04-01 12:53:58 +02:00
Reilly Wood
83ddf0ebe2
Make optional cell paths work with reject (#8697)
This PR makes `?` work with `reject`. For example:

```bash
> {} | reject foo
Error: nu:🐚:column_not_found

  × Cannot find column
   ╭─[entry #2:1:1]
 1 │ {} | reject foo
   ·      ───┬── ─┬─
   ·         │    ╰── cannot find column 'foo'
   ·         ╰── value originates here
   ╰────

> {} | reject foo?
╭──────────────╮
│ empty record │
╰──────────────╯
```

This was prompted by [a user
question](https://discord.com/channels/601130461678272522/614593951969574961/1091466428546306078).
I would like to get this in for 0.78, I think it's low-risk and I want
the `?` feature to be as polished as possible for its debut.
2023-03-31 16:40:19 -07:00
Kelvin Samuel
eaea00366b
Fix a bug with us not outputting as µs with the into duration command (#8691)
# Description

Whilst working on [Allow parsing of mu (µ) character for
durations](https://github.com/nushell/nushell/pull/8647), I found a bug
where, if you use `into duration --convert us`, it outputs with the unit
as `us` rather than `µs`

![image](https://user-images.githubusercontent.com/44570273/229141818-37f97071-7f8e-451c-9baa-3c292290e6e7.png)

After this change, it now outputs the correct symbol:

![image](https://user-images.githubusercontent.com/44570273/229142720-6e67d49a-e88f-44a8-a742-92fa5220e54b.png)

# User-Facing Changes

User will now see correct unit when converting into microseconds.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-03-31 16:01:48 -05:00
Darren Schroeder
0788fe5e72
fully deprecate str collect (#8680)
# Description

This PR fully deprecates `str collect`. It's been "half-deprecatd" for a
long time. This takes it all the way and disallows the command in favor
of `str join`.

# User-Facing Changes

No more `str collect`

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-03-31 13:23:22 -05:00
Stefan Holderbach
3bf5999ef4
Remove proptests for nuon writing/parsing (#8688)
# Description

The two tests `to_nuon_from_nuon` and `to_nuon_from_nuon_string` were
taking multiple seconds and have since been superseded by more explicit
unit tests. Compared to the time cost for devs and CI they seldomly
returned explicit problems. One failure only popped up after months, as
a sampled failure (https://github.com/nushell/nushell/pull/7564).


# User-Facing Changes

none

# Tests + Formatting

Fuzzing should move to a separate worker and be removed from the main
test suite.
See #8575 for experimentation around the impact on our test coverage.
2023-03-31 17:15:16 +02:00
Maxim Zhiburt
8a85299575
Fix of a fix of #8671 (#8675)
Hi @fdncred,

I accidentally noticed that your fix tricks wrapping a bit.


![image](https://user-images.githubusercontent.com/20165848/228908201-0d5c7878-739f-43a3-b931-a8dc9df85cd7.png)


It must address it.

PS: I believe the issue was originally caused by a false positive of
clippy. (maybe we shall report it I am not sure)

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-03-31 07:53:57 -05:00
JT
3db0aed9f7
Add rest and ignore-rest patterns (#8681)
# Description

Adds two more patterns when working with lists:

```
[1, ..$remainder]
```
and
```
[1, ..]
```
The first one collects the remaining items and assigns them into the
variable. The second one ignores any remaining values.

# User-Facing Changes

Adds more capability to list pattern matching.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-03-31 11:08:53 +13:00
Darren Schroeder
09276db2a5
add a threads parameter to par_each (#8679)
# Description

This PR allows you to control the amount of threads that `par-each` uses
via a `--threads(-t)` parameter. When no threads parameter is specified,
`par-each` uses the default, which is the same number of available CPUs
on your system.


![image](https://user-images.githubusercontent.com/343840/228935152-eca5b06b-4e8d-41be-82c4-ecd49cdf1fe1.png)

closes #4407

# User-Facing Changes

New parameter

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.nu` 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.
2023-03-30 16:39:40 -05:00
Kelvin Samuel
bc6948dc89
Allow parsing of mu (µ) character for durations (issue #8614) (#8647)
# Description
This is to resolve the issue
[8614](https://github.com/nushell/nushell/issues/8614).
It allows the parsing of the mu (µ) character for durations, so you can
type `10µs`, and it correctly outputs, whilst maintaining the current
`us` parsing as well.

It also forces `durations` to be entered in lower case. 


![image](https://user-images.githubusercontent.com/44570273/228217360-57ebc902-cec5-4683-910e-0b18fbe160b1.png)
(The bottom one `1sec | into duration --convert us` looks like an
existing bug, where converting to `us` outputs `us` rather than `µs`)

# User-Facing Changes

Allows the user to parse durations in µs
Forces `durations` to be entered in lower case rather than any case, and
will error if not in lower case.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-03-30 17:35:35 +02:00
Darren Schroeder
e9c17daecd
fix inspect panic with large tables (#8673)
# Description

This PR fixes a small bug where `inspect` was panicking because the data
returned was larger than that terminal size.

Closes #8671
Closes #8674

# User-Facing Changes

No more panic

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-30 09:54:57 -05:00
Benjamin Lee
53beba7acc
Support passing an empty list to sort, uniq, sort-by, and uniq-by (issue #5957) (#8669)
# Description

Currently, all four of these commands return a (rather-confusing)
spanless error when passed an empty list:

```
> [] | sort
Error: 
  × no values to work with
  help: no values to work with
```

This PR changes these commands to always output `[]` if the input is
`[]`.

```
> [] | sort
╭────────────╮
│ empty list │
╰────────────╯
> [] | uniq-by foo
╭────────────╮
│ empty list │
╰────────────╯
```

I'm not sure what the original logic was here, but in the case of `sort`
and `uniq`, I think the current behavior is straightforwardly wrong.

`sort-by` and `uniq-by` are a bit more complicated, since they currently
try to perform some validation that the specified column name is present
in the input (see #8667 for problems with this validation, where a
possible outcome is removing the validation entirely). When passed `[]`,
it's not possible to do any validation because there are no records.
This opens up the possibility for situations like the following:

```
> [[foo]; [5] [6]] | where foo < 3 | sort-by bar
╭────────────╮
│ empty list │
╰────────────╯
```

I think there's a strong argument that `[]` is the best output for these
commands as well, since it makes pipelines like `$table | filter
$condition | sort-by $column` more predictable. Currently, this pipeline
will throw an error if `filter` evaluates to `[]`, but work fine
otherwise. This makes it difficult to write reliable code, especially
since users are not likely to encounter the `filter -> []` case in
testing (issue #5957). The only workaround is to insert manual checks
for an empty result. IMO, this is significantly worse than the "you can
typo a column name without getting an error" problem shown above.

Other commands that take column arguments (`get`, `select`, `rename`,
etc) already have `[] -> []`, so there's existing precedent for this
behavior.

The core question here is "what columns does `[]` have"? The current
behavior of `sort-by` is "no columns", while the current behavior of
`select` is "all possible columns". Both answers lead to accepting some
likely-buggy code without throwing on error, but in order to do better
here we would need something like `Value::Table` that tracks columns on
empty tables.

If other people disagree with this logic, I'm happy to split out the
`sort-by` and `uniq-by` changes into another PR.

# User-Facing Changes

`sort`, `uniq`, `sort-by`, and `uniq-by` now return `[]` instead of
throwing an error when input is `[]`.

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

The existing behavior was not documented, and the new behavior is what
you would expect by default, so I don't think we need to update
documentation.

---------

Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
2023-03-29 19:55:38 -07:00
Antoine Stevan
ed0fce9aa6
REFACTOR: remove the redundant path expand from the tests of the standard library (#8666)
Related to #8653.

# Description
This PR removes the redundant `path expand`s introduced in #8552 and
#8576.

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
the tests still pass on linux.

# After Submitting
```
$nothing
```
2023-03-29 16:17:00 -05:00
Reilly Wood
995603b08c
Fix record-to-JSON conversion for HTTP commands (#8663)
This PR fixes a bug introduced in
https://github.com/nushell/nushell/pull/8571.

We were accidentally converting a `Result<Value, ShellError>` to JSON
instead of converting a `Value`. The upshot was that we were sending
JSON like `{"Ok":{"foo":"bar"}}` instead of `{"foo":"bar"}`.

This was an easy bug to miss, because `ureq::send_json()` accepts any
`impl serde::Serialize`. I've added a test to prevent regression.
2023-03-29 11:55:51 -07:00
Darren Schroeder
a49e5b30ff
auto-expand paths in the $nu variable (#8653)
# Description

I recently ran into an issue where one of the $nu paths was not expanded
and was causing issue because $env.PWD did not equal $nu.temp-path, even
though I was in $nu.temp-path. The reason it didn't match was because my
temp path was symlinked. This PR fixes that issue by expanding the paths
with canonicalize_with().

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-29 13:23:58 -05:00
JT
97e7d550c8
move 'str substring' to only use ranges (#8660)
# Description

This removes all the old style of quasi-ranges before we had full range
support from `str substring`. Functionality should otherwise work, but
only with the official range syntax.

# User-Facing Changes

Removes the array and string forms of ranges from `str substring`.
Leaves only the official range support for range values.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-29 20:01:42 +13:00
JT
393717dbb4
Improve inferred record types and type compat (#8649)
# Description

This allows for type inference to infer record types in more cases. The
only time we will now fall back to `Any` is when one of the fields has a
computed value.

I also updated the type mismatch error and highlighting to be in-line
with other errors.

# User-Facing Changes

This may result in stricter type checking. Previously `{}` had the
inferred type `Any` but will now have the correct inferred type of
`Record<>`.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-29 10:23:10 +13:00
Reilly Wood
da8cb14f8b
Fix select on empty lists (#8651)
This PR fixes `select` when given an empty list; it used to return
`null` when given an empty list. I also cleaned up other `select` tests
while I was in the area.

### Before:

```
> [] | select a | to nuon
null
```

### After:

```
> [] | select a | to nuon
[]
```

It looks like the previous behaviour was accidentally introduced by
[this PR](https://github.com/nushell/nushell/pull/7639).
2023-03-28 12:40:29 -07:00
Antoine Stevan
9f01cf333c
stdlib: fix the assert equal tests (#8650)
Related to #8150, #8635 and #8632.

# Description
i've introduced a bad set of tests for the `assert equal` command in
#8150...

they should not compare `1 + 2` and `4)` or `3)` but the ints.

in this PR, i remove this spurious parentheses that were not planned at
all 😬 👀


# User-Facing Changes
```
$nothing
```

# Tests + Formatting
```
>_ nu crates/nu-utils/standard_library/tests.nu
INF|2023-03-28T20:18:13.022|Running tests in test_asserts
INF|2023-03-28T20:18:13.173|Running tests in test_dirs
INF|2023-03-28T20:18:13.247|Running tests in test_logger
INF|2023-03-28T20:18:13.473|Running tests in test_std
```

# After Submitting
```
$nothing
```
2023-03-28 13:34:26 -05:00
Máté FARKAS
d391e912ff
stdlib: Add back recursive lookup for tests (#8632)
@amtoine during the refactor the test runner lost the ability for
looking up for test modules in subdirectories. I just added it back now.
2023-03-28 13:17:46 -05:00
JT
8b185a4008
Improve number-like error if expecting a string (#8645)
# Description

This should give a slightly better error if a position expects a string
and the user writes a number-like value.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-28 21:25:35 +13:00
JT
90b65018b6
Require that values that look like numbers parse as numberlike (#8635)
# Description

Require that any value that looks like it might be a number (starts with
a digit, or a '-' + digit, or a '+' + digits, or a special form float
like `-inf`, `inf`, or `NaN`) must now be treated as a number-like
value. Number-like syntax can only parse into number-like values.
Number-like values include: durations, ints, floats, ranges, filesizes,
binary data, etc.

# User-Facing Changes

BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE

Just making sure we see this for release notes 😅 

This breaks any and all numberlike values that were treated as strings
before. Example, we used to allow `3,` as a bare word. Anything like
this would now require quotes or backticks to be treated as a string or
bare word, respectively.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-28 19:31:38 +13:00
JT
7ec5f2f2eb
Add or-patterns, fix var binding scope (#8633)
# Description

Adds `|` patterns to `match`, allowing you to try multiple patterns for
the same case.

Example:

```
match {b: 1} { {a: $b} | {b: $b} => { print $b } }
```

Variables that don't bind are set to `$nothing` so that they can be
later checked.

This PR also:
fixes #8631 

Creates a set of integration tests for pattern matching also

# User-Facing Changes

Adds `|` to `match`. Fixes variable binding scope. 
# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-27 11:31:57 +13:00
Antoine Stevan
332f1192a6
stdlib: optimize test search and add better errors (#8626)
the first part of this PR comes from a request from @presidento in
#8525.
the second one is an improvement of the error support.

# Description
this PR
- computes `module_search_pattern` to only `ls` the selected modules =>
the goal is to save search time in the future with more tests
- gives better errors when
  - the `--path` is invalid
  - the `--module` does not exist
  - the search is too strict

### examples
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --path does-not-exist
Error: 
  × directory_not_found
   ╭─[<commandline>:1:1]
 1 │ main --path does-not-exist
   ·             ───────┬──────
   ·                    ╰── no such directory
   ╰────
```

```bash
>_ nu crates/nu-utils/standard_library/tests.nu --module does-not-exist
Error: 
  × module_not_found
   ╭─[<commandline>:1:1]
 1 │ main --module does-not-exist
   ·               ───────┬──────
   ·                      ╰── no such module in /home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/
   ╰────
```

```bash
>_ nu crates/nu-utils/standard_library/tests.nu --command does_not_exist
Error: 
  × no test to run
```

instead of the previous

```bash
>_ nu crates/nu-utils/standard_library/tests.nu --path does-not-exist
Error: 
  × No matches found for /home/amtoine/.local/share/git/store/github.com/amtoine/nushell/does-not-exist/test_*.nu
    ╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:32:1]
 32 │     let tests = (
 33 │         ls ($path | default $env.FILE_PWD | path join "test_*.nu")
    ·            ───────────────────────────┬───────────────────────────
    ·                                       ╰── Pattern, file or folder not found
 34 │         | each {|row| {file: $row.name name: ($row.name | path parse | get stem)}}
    ╰────
  help: no matches found
```

```bash
>_ nu crates/nu-utils/standard_library/tests.nu --module does-not-exist
Error: 
  × expected table from pipeline
    ╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:59:1]
 59 │         $tests_to_run
 60 │         | group-by module
    ·           ────┬───
    ·               ╰── requires a table input
 61 │         | transpose name tests
    ╰────
```

```bash
>_ nu crates/nu-utils/standard_library/tests.nu --command does-not-exist
Error: 
  × expected table from pipeline
    ╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:59:1]
 59 │         $tests_to_run
 60 │         | group-by module
    ·           ────┬───
    ·               ╰── requires a table input
 61 │         | transpose name tests
    ╰────
```

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-03-26 08:09:26 -05:00
WindSoilder
944cad35bf
When running external command, expand tilde when pass back-quoted word (#8561)
# Description

Fixes: #8542

# User-Facing Changes

## Previous
```
❯ cat `~/TE ST/bug`
cat: ~/TE ST/bug: No such file or directory
```

## After
```
❯ cat `~/TE ST/bug`
a
```

This should be ok because We treat back-quoted strings as bare words

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-26 22:17:51 +13:00
mike
86ae27b0c1
fix unhelpful error message with extra characters in list annotations (#8619)
# Description

with such a line
```nu
def err [list: list<>extra] {}
```
this pr changes the error message from 
```nu
Error: nu::parser::unclosed_delimiter

  × Unclosed delimiter.
   ╭─[entry #69:1:1]
 1 │ def err [list: list<>extra] {}
   ·                ─────┬─────
   ·                      ╰── unclosed >
   ╰────
```
to
```nu
  × Extra characters in the parameter name.
   ╭─[entry #69:1:1]
 1 │ def err [list: list<>extra] {}
   ·                      ──┬──
   ·                        ╰── extra characters
   ╰────
```
2023-03-26 10:59:47 +02:00
mike
d9a888528a
fix unhelpful error message with '@' custom completion (#8620)
# Description

with such a line 
```nu
extern err [--flag: string@]
```
this pr changes the error message from
```nu
Error: nu::parser::unknown_command

  × Unknown command.
   ╭─[entry #69:1:1]
 1 │ extern err [--flag: string@]
   ·                            ▲
   ·                            ╰── unknown command
   ╰────
```
to
```nu
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #69:1:1]
 1 │ extern err [--flag: string@]
   ·                            ▲
   ·                            ╰── expected command name
   ╰────
```
2023-03-26 10:58:33 +02:00
Antoine Stevan
05f1b41275
remove match from the standard library (#8625)
Should close #8616.
Related to #8590.

# Description
With the new builtin `match` command introduced in the `rust` source in
#8590, there is no need to have a custom `match` in the standard
library.
This PR removes the `match` command from `std.nu` and the associated
test.

# User-Facing Changes
Users can not access `match` from `std.nu`.

# Tests + Formatting
```
nu crates/nu-utils/standard_library/tests.nu  --path crates/nu-utils/standard_library/ out+err> /dev/null; ($env.LAST_EXIT_CODE == 0)
```
gives `true`

# After Submitting
```
$nothing
```
2023-03-26 10:57:41 +02:00
JT
5b03bca138
Remove autoprinting of loop block values (#8618)
# Description

This removes autoprinting the final value of a loop, much in the same
spirit as not autoprinting values at the end of statements. As we fix
these corner cases, it becomes more consistent that to print to the
screen in a script, you use the `print` command.

This gives a noticeable performance improvement as a bonus.

Before:
```
C:\Source\nushell〉 for x in 1..10 { $x }
1
2
3
4
5
6
7
8
9
10
```
Now:
```
C:\Source\nushell〉 for x in 1..10 { $x }
C:\Source\nushell〉
```

# User-Facing Changes

**BREAKING CHANGE**

Loops like `for`, `loop`, and `while` will no longer automatically print
loop values to the screen.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-26 13:23:54 +13:00
Reilly Wood
d409171ba8
Change comparison operators to allow nulls (#8617)
Prior to this PR, the less/greater than operators (`<`, `>`, `<=`, `>=`)
would throw an error if either side was null. After this PR, these
operators return null if either side (or both) is null.

### Examples
```bash 
1 < 3       # true
1 < null    # null
null < 3    # null
null < null # null
```

### Motivation

JT [asked the C#
folks](https://discord.com/channels/601130461678272522/615329862395101194/1086137515053957140)
and this is apparently the approach they would choose for comparison
operators if they could start from scratch.

This PR makes `where` more convenient to use on jagged/missing data. For
example, we can now filter on columns that may not be present in every
row:
```
> [{foo: 123} {}] | where foo? > 10
╭───┬─────╮
│ # │ foo │
├───┼─────┤
│ 0 │ 123 │
╰───┴─────╯
```
2023-03-26 12:10:09 +13:00
Antoine Stevan
0567407f85
standard library: bring the tests into the main CI (#8525)
Should close one of the tasks in #8450.

# Description
> **Note**
> in order of appearance in the global diff

- 1b7497c419 adds the `std-tests` job to
the CI which
  1. installs `nushell` in the runner
  2. run the `tests.nu` module
> see `open .github/workflows/ci.yml | get jobs.std-tests | to yaml`

-
[`ec85b6fd`..`9c122115`](ec85b6fd3fc004cd94e3fada5c8e5fe2714fd629..9c12211564ca8ee90ed65ae45776dccb8f8e4ef1)
is where all the magic happens => see below
- 🧪 799c7eb7fd introduces some
bugs and failing test to see how the CI behaves => see how the [tests
failed](https://github.com/nushell/nushell/actions/runs/4460098237/jobs/7833018256)
as expected 
- 🧪 and c3de1fafb5 reverts the
failing tests, i.e. the previous commit, leaving a standard library
whose tests all pass 🎉 => see the [tests
passing](https://github.com/nushell/nushell/actions/runs/4460153434/jobs/7833110719?pr=8525#step:5:1)
now ✔️

## the changes to the runner
> see
[`ec85b6fd`..`9c122115`](ec85b6fd3fc004cd94e3fada5c8e5fe2714fd629..9c12211564ca8ee90ed65ae45776dccb8f8e4ef1)

the issue with the previous runner was the following: the clever trick
of using `nu -c "use ...; test"` did print the errors when occuring but
they did not capture the true "failure", i.e. in all cases the
`$env.LAST_EXIT_CODE` was set to `0`, never stopping the CI when a test
failed 🤔

i first tried to `try` / `catch` the error in
ec85b6fd3f which kinda worked but only
throw a single error, the first one

i thought it was not the best and started thinking about a solution to
have a complete report of all failing tests, at once, to avoid running
the CI multiple times!

the easiest solution i found was the one i implemented in
9c12211564
> **Warning**
> this changes the structure of the runner quite a bit, but the `for`
loops where annoying to manipulate structured data and allow the runner
to draw a complete report...

now the runner does the following
- compute the list of all available tests in a table with the `file`,
`module` and `name` columns (first part of the pipe until `flatten` and
`rename`)
- run the tests one by one computing the new `pass` column
  - with a `log info`
- captures the failing ones => puts `true` in `pass` if the test passes,
`false` otherwise
- if at least one test has failed, throw a single error with the list of
failing tests

### hope you'll like it 😌 

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
the standard tests now return a true error that will stop the CI

# After Submitting
```
$nothing
```
2023-03-25 19:29:08 +01:00
JT
6872d2ac2a
Speed up tight loop benchmarks (#8609)
# Description

This does a few speedups for tight loops:
* Caches the DeclId for `table` so we don't look it up. This means users
can't easily replace the default one, we might want to talk about this
tradeoff. The lookup for finding `table` in a tight loop is currently
pretty heavy. Might be another way to speed this up.
* `table` no longer pre-calculates the width. Instead, it only
calculates the width when printing a table or record.
* Use more efficient way of collecting the block of each loop
* When printing output, only get the config when needed

Combined, this drops the runtime from a million loop tight iteration
from 1sec 8ms to 236ms.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-26 06:12:57 +13:00
Reilly Wood
d8478ca690
Clean up unnecessary macro use (#8607)
Some minor code cleanup.

We've accumulated a few macros over the years that arguably don't need
to be macros. This PR removes 4 macros by either:
1. Inlining the macro
2. Replacing the macro with a local function
3. Replacing the macro with a closure
2023-03-25 20:17:20 +13:00
JT
aab31833a2
Add more pattern types to matcher (#8605)
# Description

Add float, string, and date patterns to matcher.

This could probably use some tests 😅 

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-25 17:30:35 +13:00
JT
c0648a83be
Move variables to var stack (#8604)
# Description

This moves the representation of variables on the stack to a Vec, which
more closely resembles a stack. For small numbers of variables live at
any one point, this tends to be more efficient than a HashMap. Having a
stack-like vector also allows us to remember a stack position,
temporarily push variables on, then quickly drop the stack back to the
original size when we're done. We'll need this capability to allow
matching inside of conditions.

On this mac, a simple run of:

`timeit { mut x = 1; while $x < 1000000 { $x += 1 } }`

Went from 1 sec 86 ms, down to 1 sec 2 ms. Clearly, we have a lot more
ground we can make up in looping speed 😅 but it's nice that for fixing
this to make matching easier, we also get a win in terms of lookup speed
for small numbers of variables.

# User-Facing Changes

Likely users won't (hopefully) see any negative impact and may even see
a small positive impact.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-25 12:56:45 +13:00
mike
744a28b31d
type-check default values of list annotations (#8600)
# Description

@fdncred noticed an
[issue](https://github.com/nushell/nushell/pull/8529#issuecomment-1482770636)
with list annotations that while i was trying to find a fix found
another issue.

innitially, this was accepted by the parser
```nu
def err [list: list<int> = ['a' 'b' 'c']] {}
```

but now an error is raised
```nu
Error: nu::parser::assignment_mismatch

  × Default value wrong type
   ╭─[entry #1:1:1]
 1 │ def err [list: list<int> = ['a' 'b' 'c']] {}
   ·                            ──────┬────
   ·                                   ╰── expected default value to be `list<int>`
   ╰────
```

# User-Facing Changes

none

# Tests + Formatting

done
2023-03-25 08:57:18 +13:00
Reilly Wood
b4b68afa17
Make HTTP requests cancellable when trying to connect (#8591)
Closes #8585.

Prior to this change, the `http` commands could get stuck for 30s while
attempting to make a connection to a remote server. After this change,
`ctrl+c` works as expected:


![image](https://user-images.githubusercontent.com/26268125/227395505-c2d5b19d-6228-4eac-836f-c0c3426b0c19.png)

To make this work, we perform blocking `ureq` calls in a background
thread and poll the channel while checking `ctrl+c`.
2023-03-24 12:45:55 -07:00
mike
8cf9bc9993
allow lists to have type annotations (#8529)
this pr refines #8270 and closes #8109

# description
examples:

the original syntax is okay
```nu
def okay [nums: list] {}         # the type of list will be list<any>
```

empty annotations are allowed in any variation
the last two may be caught by a future formatter, 
but do not affect `nu` code currently
```nu
def okay [nums: list<>] {}       # okay

def okay [nums: list<     >] {}  # weird but also okay

def okay [nums: list<
>] {}                            # also weird but okay
```

types are allowed (See [notes](#notes) below)
```nu
def okay [nums: list<int>] {}    # `test [a b c]` will throw an error 

def okay [nums: list< int > {}   # any amount of space within the angle brackets is okay

def err [nums: list <int>] {}    # this is not okay, `nums` and `<int>` will be parsed as
                                 # two separate params, 
```

nested annotations are allowed in many variations
```nu
def okay [items: list<list<int>>] {}

def okay [items: list<list>] {}
```

any unterminated annotation is caught
```nu
Error: nu::parser::unexpected_eof

  × Unexpected end of code.
   ╭─[source:1:1]
 1 │ def err [nums: list<int] {}
   ·                       ▲
   ·                       ╰── expected closing >
   ╰────
```

unknown types are flagged
```nu
Error: nu::parser::unknown_type

  × Unknown type.
   ╭─[source:1:1]
 1 │ def err [nums: list<str>] {}
   ·                     ─┬─
   ·                      ╰── unknown type
   ╰────

Error: nu::parser::unknown_type

  × Unknown type.
   ╭─[source:1:1]
 1 │ def err [nums: list<int, string>] {}
   ·                    ─────┬─────
   ·                          ╰── unknown type
   ╰────
```

# notes
the error message for mismatched types in not as intuitive
```nu
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[source:1:1]
 1 │ def err [nums: list<int>] {}; err [a b c]
   ·                                    ┬
   ·                                    ╰── expected int
   ╰────
```
it should be something like this
```nu
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[source:1:1]
 1 │ def err [nums: list<int>] {}; err [a b c]
   ·                                    ──┬──
   ·                                      ╰── expected list<int>
   ╰────
```
this is currently not implemented
2023-03-24 12:54:06 +01:00
uaeio
d0aa69bfcb
Decode and Encode hex (#8392)
# Description

I need a command that will transform hex string into bytes and into
other direction.

I've implemented `decode hex` command and `encode hex` command. (Based
on `encode base64` and `decode base64` commands
# User-Facing Changes

```
> '010203' | decode hex
0x[01 02 03]
```

and 

```
> 0x[01 02 0a] | encode hex
'01020A'
```

---------

Co-authored-by: whiteand <andrewbeletskiy@gmail.com>
2023-03-24 12:25:26 +01:00
dependabot[bot]
4a1d12462f
Bump miette from 5.5.0 to 5.6.0 (#8531)
Bumps [miette](https://github.com/zkat/miette) from 5.5.0 to 5.6.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/zkat/miette/blob/main/CHANGELOG.md">miette's
changelog</a>.</em></p>
<blockquote>
<h2>5.6.0 (2023-03-14)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>ci:</strong> configure clippy-specific MSRV (<a
href="b658fc020b">b658fc02</a>)</li>
<li><strong>graphical:</strong> Fix wrong severity of related errors (<a
href="https://redirect.github.com/zkat/miette/issues/234">#234</a>) (<a
href="3497508aa9">3497508a</a>)</li>
<li><strong>atty:</strong> Switch out <code>atty</code> for
<code>is-terminal</code> (<a
href="https://redirect.github.com/zkat/miette/issues/229">#229</a>) (<a
href="443d240f49">443d240f</a>)</li>
</ul>
<h3>Features</h3>
<ul>
<li><strong>protocol:</strong> implement <code>Ord</code> for
<code>Severity</code> (<a
href="https://redirect.github.com/zkat/miette/issues/240">#240</a>) (<a
href="ed486c959d">ed486c95</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="78fe18e699"><code>78fe18e</code></a>
chore: Release</li>
<li><a
href="2335b25ee7"><code>2335b25</code></a>
docs: update changelog</li>
<li><a
href="443d240f49"><code>443d240</code></a>
fix(atty): Switch out <code>atty</code> for <code>is-terminal</code> (<a
href="https://redirect.github.com/zkat/miette/issues/229">#229</a>)</li>
<li><a
href="ed486c959d"><code>ed486c9</code></a>
feat(protocol): implement <code>Ord</code> for <code>Severity</code> (<a
href="https://redirect.github.com/zkat/miette/issues/240">#240</a>)</li>
<li><a
href="3497508aa9"><code>3497508</code></a>
fix(graphical): Fix wrong severity of related errors (<a
href="https://redirect.github.com/zkat/miette/issues/234">#234</a>)</li>
<li><a
href="b658fc020b"><code>b658fc0</code></a>
fix(ci): configure clippy-specific MSRV</li>
<li><a
href="ebc61b5cf8"><code>ebc61b5</code></a>
docs: Mention miette::miette! macro under &quot;... in application
code&quot; (<a
href="https://redirect.github.com/zkat/miette/issues/233">#233</a>)</li>
<li><a
href="14f952dc91"><code>14f952d</code></a>
(cargo-release) start next development iteration 5.5.1-alpha.0</li>
<li><a
href="128c0a1fae"><code>128c0a1</code></a>
(cargo-release) start next development iteration 5.5.1-alpha.0</li>
<li>See full diff in <a
href="https://github.com/zkat/miette/compare/miette-derive-v5.5.0...miette-derive-v5.6.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=miette&package-manager=cargo&previous-version=5.5.0&new-version=5.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 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>
2023-03-24 22:55:25 +13:00
JT
8d5fbc6fcb
Fix closures that use matches. Move 'collect' to core. (#8596)
# Description

Fix patterns in pattern matching to properly declare their variables
when discovering which variables need to be closed over when creating a
closure.

Also, moves `collect` to core, so that the core language can use `$in`.

Fixes #8595 

# User-Facing Changes

See above

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-24 22:50:23 +13:00
JT
85bfdba1e2
Make timeit work with command calls (#8594)
# Description

Allows `timeit` to also run commands directly, eg) `timeit ls -la`

# User-Facing Changes

Additional capabilities to `timeit`.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-24 22:34:03 +13:00
JT
546c753d1e
Move timeit to use blocks. Make match vars immutable (#8592)
# Description

This does a couple random changes/fixes:

* Moves `timeit` to use a block instead of a closure. This makes it a
bit more flexible.
* Moves var bindings in patterns to be immutable

# User-Facing Changes

`timeit` now takes a block and no arguments.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-24 17:33:11 +13:00
JT
2c3aade057
Add pattern matching (#8590)
# Description

This adds `match` and basic pattern matching.

An example:

```
match $x {
  1..10 => { print "Value is between 1 and 10" }
  { foo: $bar } => { print $"Value has a 'foo' field with value ($bar)" }
  [$a, $b] => { print $"Value is a list with two items: ($a) and ($b)" }
  _ => { print "Value is none of the above" }
}
```

Like the recent changes to `if` to allow it to be used as an expression,
`match` can also be used as an expression. This allows you to assign the
result to a variable, eg) `let xyz = match ...`

I've also included a short-hand pattern for matching records, as I think
it might help when doing a lot of record patterns: `{$foo}` which is
equivalent to `{foo: $foo}`.

There are still missing components, so consider this the first step in
full pattern matching support. Currently missing:
* Patterns for strings
* Or-patterns (like the `|` in Rust)
* Patterns for tables (unclear how we want to match a table, so it'll
need some design)
* Patterns for binary values
* And much more

# User-Facing Changes

[see above]

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-24 14:52:01 +13:00
Darren Schroeder
be52f7fb07
tweak logging format (#8588)
# Description

This PR just tweaks the std.nu logging a bit. It looks like this after
this PR. I like the ability to have a parse-able file, which is why
there are pipes, and I like to have a pretty granular time date stamp in
order to get rough performance metrics.
```
nu crates\nu-utils\standard_library\tests.nu
INF|2023-03-23T15:02:00.284|Run test test_asserts test_assert
INF|2023-03-23T15:02:00.372|Run test test_asserts test_assert_equal
INF|2023-03-23T15:02:00.461|Run test test_asserts test_assert_error
INF|2023-03-23T15:02:00.585|Run test test_asserts test_assert_greater
INF|2023-03-23T15:02:00.674|Run test test_asserts test_assert_greater_or_equal
INF|2023-03-23T15:02:00.762|Run test test_asserts test_assert_length
INF|2023-03-23T15:02:00.847|Run test test_asserts test_assert_less
INF|2023-03-23T15:02:00.933|Run test test_asserts test_assert_less_or_equal
INF|2023-03-23T15:02:01.021|Run test test_asserts test_assert_not_equal
INF|2023-03-23T15:02:01.110|Run test test_dirs test_dirs_command
INF|2023-03-23T15:02:01.300|Run test test_logger test_critical
INF|2023-03-23T15:02:01.558|Run test test_logger test_debug
INF|2023-03-23T15:02:01.818|Run test test_logger test_error
INF|2023-03-23T15:02:02.074|Run test test_logger test_info
INF|2023-03-23T15:02:02.331|Run test test_logger test_warning
INF|2023-03-23T15:02:02.573|Run test test_std test_match
INF|2023-03-23T15:02:02.678|Run test test_std test_path_add
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-23 15:59:49 -05:00
Sygmei
ec5396a352
feat: added multiple options to http commands (#8571)
# Description

All `http` commands now have a `-f` flag which for now contains the
`headers`, `body` and `status` fields (we can later add stuff like
`is-redirect` or `cookies`).


![image](https://user-images.githubusercontent.com/3835355/227048504-6686445d-ad2e-4f5d-905d-e71b3a4b81a6.png)

*Try it yourself*
```
http get http://mockbin.org/bin/630069dc-2c09-483a-a484-672561b7de14
http get -f http://mockbin.org/bin/630069dc-2c09-483a-a484-672561b7de14
```

The `http` commands can also now use the `-e` flag, which stands for
`--allow-errors`. When the status code is `>= 400`, it will still allow
you to interpret it like a normal response.


![image](https://user-images.githubusercontent.com/3835355/227047790-b9f5a25f-2c0d-4741-881f-4189b23e4ef6.png)

*Try it yourself*
```
http get http://mockbin.org/bin/2ebd3d27-bdc2-4ee8-b042-0bc2c0d1ad2a # should fail like usual
http get -e http://mockbin.org/bin/2ebd3d27-bdc2-4ee8-b042-0bc2c0d1ad2a # will return the body
http get -e -f http://mockbin.org/bin/2ebd3d27-bdc2-4ee8-b042-0bc2c0d1ad2a # will let you see the full response
```

# User-Facing Changes

- Adds `-f` (`--full`) to all `http` commands
- Adds `-e` (--allow-errors) to all `http` commands
2023-03-23 13:32:35 -07:00
mike
403bf1a734
unify the run functions of all and any (#8578)
# Description

this pr reduces duplication by making `any` and `all` commands use [one
function](66ad83c15c/crates/nu-command/src/filters/any.rs (LL63-L65C28))
2023-03-23 20:49:52 +01:00
Antoine Stevan
05ff7a9925
FIX: do not allow *start > end* in error make spans (#8570)
This should close #8567.

# Description
this PR throws an error when `start > end` in the most complete branch
of `ErrorMake::run`, i.e. when `$.msg`, `$.label.text`, `$.label.start`
and `$.label.end` are defined.

i've also added a `error_start_bigger_than_end_should_fail` test to
check that it does indeed return the right error.

# User-Facing Changes
no more crash when manipulating span bounds and a clear error, e.g.
```bash
>_ error make {msg: "msg" label: {text: "text" start: 1010 end: 1000}}
Error:
  × invalid error format.
   ╭─[entry #3:1:1]
 1 │ error make {msg: "msg" label: {text: "text" start: 1010 end: 1000}}
   ·                               ──────────────────┬─────────────────
   ·                                                 ╰── `$.label.start` is stricly bigger than `$.label.end`
   ╰────
  help: 1010 > 1000
```
or
```bash
>_ error make {
:::     msg: "msg"
:::     label: {
:::         text: "text"
:::         start: ($nu.scope.engine_state.source_bytes - 90)
:::         end: ($nu.scope.engine_state.source_bytes - 100)
:::     }
::: }
Error:
  × invalid error format.
   ╭─[entry #4:2:1]
 2 │         msg: "msg"
 3 │ ╭─▶     label: {
 4 │ │           text: "text"
 5 │ │           start: ($nu.scope.engine_state.source_bytes - 90)
 6 │ │           end: ($nu.scope.engine_state.source_bytes - 100)
 7 │ ├─▶     }
   · ╰──── `$.label.start` is stricly bigger than `$.label.end`
 8 │     }
   ╰────
  help: 204525 > 204515
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🔴 `toolkit test`

# After Submitting
```
$nothing
```
2023-03-23 20:31:06 +01:00
Reilly Wood
5c2a767987
Better error message for mv when file not found (#8586)
Closes #8546.

### Before:
```
> mv foo.txt bar.txt
Error:
  × Invalid file or pattern
   ╭─[entry #2:1:1]
 1 │ mv foo.txt bar.txt
   ·    ───┬───
   ·       ╰── invalid file or pattern
   ╰────
```

### After:
```
> mv foo.txt bar.txt
Error:
  × File(s) not found
   ╭─[entry #2:1:1]
 1 │ mv foo.txt bar.txt
   ·    ───┬───
   ·       ╰── could not find any files matching this glob pattern
   ╰────
```
2023-03-23 11:31:49 -07:00
Darren Schroeder
35798ce0cc
Clarify how register works (#8583)
# Description

This PR changes some help text to try and clarify how `register` works
when using from `nu -c`.


# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-23 13:02:22 -05:00
Darren Schroeder
616f065324
make std.nu tests work on mac (#8576)
# Description

This PR is to make test_dirs.nu work better on macos.

closes #8528

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-23 07:08:01 -05:00
Darren Schroeder
1e39a1a7a3
fixes the ability to have multiple modifiers on keybindings (#8579)
# Description

This PR fixes a bug that prevented you from having multiple modifiers on
your keybindings.

TODO:
- The docs need to be fixed too
https://www.nushell.sh/book/line_editor.html#keybindings.
(https://github.com/nushell/nushell.github.io/pull/840)
- I think reedline needs to be changed to show this too since it
provides the list of available modifiers.
(https://github.com/nushell/reedline/pull/559)

Now you can do something like this where `shift` and `alt` are combined
with an underscore.
```
  {
    name: fuzzy_history_fzf
    modifier: shift_alt
    keycode: char_r
    mode: [emacs , vi_normal, vi_insert]
    event: {
blah
}
```
Here's the list of available combinations
```rust
        "control" => KeyModifiers::CONTROL,
        "shift" => KeyModifiers::SHIFT,
        "alt" => KeyModifiers::ALT,
        "none" => KeyModifiers::NONE,
        "shift_alt" | "alt_shift" => KeyModifiers::SHIFT | KeyModifiers::ALT,
        "control_shift" | "shift_control" => KeyModifiers::CONTROL | KeyModifiers::SHIFT,
        "control_alt" | "alt_control" => KeyModifiers::CONTROL | KeyModifiers::ALT,
        "control_alt_shift" | "control_shift_alt" => {
            KeyModifiers::CONTROL | KeyModifiers::ALT | KeyModifiers::SHIFT
        }
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-23 07:07:14 -05:00
Christian Friedow
66ad83c15c
from ssv --aligned-columns should separate lines by character index instead of byte index (#8558)
# Description

## Symptom
Lines which are input into `from ssv --aligned-columns` are split
incorrectly of they contain utf-8 characters which have the length of
multiple bytes. Notice how the values of the `Bars` column bleeds into
the `Security` column in the following output (the big grey areas are
censored data ;) ):

![before-patch](https://user-images.githubusercontent.com/17351844/226757737-be7ca493-5c64-4a91-9153-984df515bb8c.png)

## Problem
The function behind `from ssv --aligned-columns` splits lines into
fields by byte index (which is default behavior of str.get(...) in Rust)
instead of character index. If the header row has a different length in
bytes than the remaining table rows, the split is executed incorrectly.

## Solution
The function behind `from ssv --aligned-columns1 now separates lines by
character index instead of byte index. This productes the following
(correct) output (the big grey areas are censored data ;) ):

![after-patch](https://user-images.githubusercontent.com/17351844/226757850-7acaebf3-2d40-4f85-b76e-64e465254bda.png)
2023-03-22 17:54:18 -05:00
Jakub Žádník
c48e9cdf5b
Disable alias recursion (for real) (#8557) 2023-03-22 23:16:06 +02:00
Reilly Wood
6a274b860a
Cell paths: make optional path members short-circuit (#8554)
This is a follow-up to https://github.com/nushell/nushell/pull/8379 and
https://github.com/nushell/nushell/discussions/8502.

This PR makes it so that the new `?` syntax for marking a path member as
optional short-circuits, as voted on in the
[8502](https://github.com/nushell/nushell/discussions/8502) poll.
Previously, `{ foo: 123 }.bar?.baz` would raise an error:

```
> { foo: 123 }.bar?.baz
  × Data cannot be accessed with a cell path
   ╭─[entry #15:1:1]
 1 │ { foo: 123 }.bar?.baz
   ·                   ─┬─
   ·                    ╰── nothing doesn't support cell paths
   ╰────
   ```

Here's what was happening:

1. The `bar?` path member access returns `nothing` because there is no field named `bar` on the record
2. The `baz` path member access fails when trying to access a `baz` field on that `nothing` value

After this change, `{ foo: 123 }.bar?.baz` returns `nothing`; the failed `bar?` access immediately returns `nothing` and the `baz` access never runs.
2023-03-23 09:54:19 +13:00
JT
2f8a52d256
Switch let/let-env family to init with math expressions (#8545)
# Description

This is an experiment to see what switching the `let/let-env` family to
math expressions for initialisers would be like.

# User-Facing Changes

This would require any commands you call from `let x = <command here>`
(and similar family) to call the command in parentheses. `let x = (foo)`
to call `foo`.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-23 09:14:10 +13:00
Jérémy Audiger
0f4a073eaf
Remove once_cell dependency from nu-test-support create. (#8568)
I was looking where we could remove the usage of once-cell dependency.
As for now, I only found one place. Not a terrible improvement, but at
least, it removes a dependency nu-test-support crate.

Relies on `Mutex::new` constified in Rust 1.63.0
2023-03-22 19:36:52 +01:00
Antoine Stevan
626410b2aa
FEATURE: write better errors for error make and complete the doc (#8511)
# Description
this PR
- refactors `ErrorMake::run` to avoid duplicate branches depending on
the value of `--unspanned`
- completes the examples
1. show a really simple `error make` call, without any command
definition
  2. show a complete error format with all possible fields
3. the command definition but with indentation and slightly better
description
- adds results to the first two examples
- gives meaningful error messages for all known "bad" error formats,
using the span of the error format or the span of `$format.label` to
better explain why the format is bad

# User-Facing Changes
users have now the following help
```bash
Examples:
  Create a simple custom error
  > error make {msg: "my custom error message"}

  Create a more complex custom error
  > error make {
        msg: "my custom error message"
        label: {
            text: "my custom label text"  # not mandatory unless $.label exists
            start: 123  # not mandatory unless $.label.end is set
            end: 456  # not mandatory unless $.label.start is set
        }
    }

  Create a custom error for a custom command that shows the span of the argument
  > def foo [x] {
        let span = (metadata $x).span;
        error make {
            msg: "this is fishy"
            label: {
                text: "fish right here"
                start: $span.start
                end: $span.end
            }
        }
    }
```
and the following error messages when the error format is bad
https://asciinema.org/a/568107 🥳

# Tests + Formatting
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🔴 `cargo test --workspace`
=> the tests do not pass but they do not pass on latest `main` either =>
i should `cargo clean`, but that's an expensive operation on my
machine...

# After Submitting
the documentation would have to be regenerated over on the website
2023-03-22 08:06:47 -05:00
dependabot[bot]
a193b85123
Bump alphanumeric-sort from 1.4.4 to 1.5.0 (#8532) 2023-03-22 13:02:45 +00:00
dependabot[bot]
0f40c44ed2
Bump windows from 0.44.0 to 0.46.0 (#8535) 2023-03-22 13:02:03 +00:00
WindSoilder
cd6f86052d
better error message if plugin name doesn't starts with nu_plugin_ (#8562)
# Description

Fixes: #8548 

# User-Facing Changes
```
❯ register target/debug/formats
Error:
  × Register plugin failed
   ╭─[entry #1:1:1]
 1 │ register target/debug/formats
   ·          ──────────┬─────────
   ·                    ╰── plugin name must starts with nu_plugin_
   ╰────

```
# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-22 07:02:28 -05:00
Steven Xu
b9858ea8f8
fix: set repl_buffer_state to the REPL buffer after the `pre_execut… (#8560)
…ion` hook


# Description

Previously when a `executehostcommand` shortcut calls `commandline`, to
get the current command line, it's incorrectly set to the value of
`executehostcommand` `cmd`.

This fixes the regression (due to #8207), so it's correctly set to
what's in the REPL buffer.

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-22 06:43:25 -05:00
Antoine Stevan
cb1eefd24a
FIX: expand all the base_paths in std::test_dirs (#8552)
Related to #8525.

# Description

this should close #8528.

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-03-22 09:50:01 +01:00
Sygmei
a1840e9d20
fix: fixed typo and improved Value TypeMismatch exceptions (#8324)
# Description

This PR aims to improve `TypeMismatch` exception that occurs when
comparing two values with `<`, `>`, `<=` or `>=` operators.

*Before*

![image](https://user-images.githubusercontent.com/3835355/222980803-8cb0f945-5a82-4512-9989-5df0ec4e4969.png)

*After*

![image](https://user-images.githubusercontent.com/3835355/226754903-68e56344-065d-42ee-b184-ab968e91c6de.png)

This PR also bundles a small refactor for histogram forbidden column
names exception, previous implementation forgot a column name in the
message, to avoid this, I'm re-using the same array for checking and
error display

# User-Facing Changes

Not much changes except a better and more readable exception for the
user

# Tests + Formatting

Does not break any tests, formatting passes as well :)
2023-03-22 09:47:40 +01:00
mike
e89c796b41
fix: bytes length example description typo (#8550)
this pr fixes a typo
2023-03-21 11:41:37 -05:00
Antoine Stevan
758351c732
FEATURE: add --raw. --tabs and --indent to to nuon as in to json (#8366)
Should close #7255.

# Description
**TL;DR**: this PR adds `--indent <int>`, `--tabs <int>` and `--raw` to
control a bit more the `string` output of `to nuon`, as done in `to
json` already, the goal being to promote the `NUON` format through easy
to read and formatted output `.nuon` files 😋

### outside of `crates/nu-command/src/formats/to/nuon.rs`
as the signature of `value_to_string` has changed, the single call to it
outside of its module definition has been changed to use default values
=> `value_to_string(&value, Span::unknown(), 0, &None)` in
`crates/nu-command/src/filters/uniq.rs`

### changes to `ToNuon` in `crates/nu-command/src/formats/to/nuon.rs`
- the signature now features `--raw`, `--indent <int>` and `--tabs
<int>`
- the structure of the `run` method is inspired from the one in `to
json`
  - we get the values of the arguments
  - we convert the input to a usable `Value`
- depending on whether the user raised `--raw`, `--indent` or `--tabs`,
we call the conversion to `string` with different values of the
indentation, starting at depth 0
- finally, we return `Ok` or a `ShellError::CantConvert` depending on
the conversion result
- some tool functions
- `get_true_indentation` gives the full indentation => `indent` repeated
`depth` times
- `get_true_separators` gives the line and field separators => a `("\n",
"")` when using some formatting or `("", " ")` when converting as pure
string on a single line

the meat of `nuon.rs` is now the `value_to_string` recursive function:
- takes the depth and the indent string
- adds correct newlines, space separators and indentation to the output
- calls itself with the same indent string but `depth + 1` to increase
the indentation by one level
- i used the `nl`, `idt`, `idt_po` (**i**n**d**en**t** **p**lus **o**ne)
and `idt_pt` (**i**n**d**en**t** **p**lus **t**wo) to make the
`format!`s easier to read

# User-Facing Changes
users can now
- control the amount and nature of NUON string output indentation with
  - `--indent <number of " " per level>`
  - `--tabs <number of "\t" per level>` 
- use the previous behaviour of `to nuon` with the `--raw` option
- have new examples with `help to nuon`

> **Note**
> the priority order of the options is the following
> 1. `--raw`
> 2. `--tabs`
> 3. `--indent`
>
> the default is `--indent 2`

# Tests + Formatting
### new tests
- tests involving the string output of `to nuon`, i.e. tests not of the
form `... | to nuon | from nuon ...`, now use the `to nuon --raw`
command => this is the smallest change to have the tests pass, as the
new `to nuon --raw` is equivalent to the old `to nuon`
- in `crates/nu-command/src/formats/to/nuon.rs`, the previous example
has been replaced with three examples
  - `[1 2 3] | to nuon` to show the default behaviour
  - `[1 2 3] | to nuon --raw` to show the not-formatted output
- a more complex example with `{date: 2000-01-01, data: [1 [2 3] 4.56]}
| to nuon`
  - the result values have been defined and the `examples` tests pass
 
### dev
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🟢 `cargo test --workspace` ~~passes but without
`to_nuon_errs_on_closure`~~ fixed in
0b4fad7eff

# After Submitting
the `to nuon` page would have to be regenerated at some point due to the
new tests
2023-03-20 15:47:18 -05:00
Máté FARKAS
77d33766f1
std lib: extend test runner capabilities (#8499)
I am implementing a nu plugin, and want to unit test that it works well.

# Basic usage (unchanged)


![image](https://user-images.githubusercontent.com/282320/225895139-f1ea0088-22e1-4778-b27e-c1868af48753.png)

# Select the folder to run tests within (subfolders included)


![image](https://user-images.githubusercontent.com/282320/225894283-4c6ac739-afde-44ef-bf7e-362d5118e83f.png)

# Select module to run tests within


![image](https://user-images.githubusercontent.com/282320/225894438-f39690db-955d-4d66-818f-17a179b00c66.png)

# Select test command to run


![image](https://user-images.githubusercontent.com/282320/225894534-edb15b9c-d3ef-4368-9108-2d220ef75dcf.png)

# Complex usage


![image](https://user-images.githubusercontent.com/282320/225894827-03f2e937-3984-4b33-b206-c155c723feac.png)

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-20 18:48:48 +01:00
dependabot[bot]
b0be6c3013
Bump quick-xml from 0.27.1 to 0.28.1 (#8533) 2023-03-20 17:46:28 +00:00
dependabot[bot]
9c6bfc0be9
Bump rstest from 0.16.0 to 0.17.0 (#8534) 2023-03-20 17:27:29 +00:00
alesito85
77e73cef66
Ls symlink fix (#8276)
# Description

Fixes #6706.

I took a look at this issue and it seems that the issue is because the
path is canonicalized and thus derives to the target. I've tested it
locally by checking if the path is a symlink and acting accordingly to
not canonicalize it and it seems fine.

In current release if the target is deleted but the symlink remains and
one `ls`'s it, it throws a `directory not found` error. But with the fix
it still shows the symlink (with red background, indicating missing
target).

The change I've applied only triggers when `ls` is done on a symlink, on
all other counts it should basically do the same as before.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

## List existing symlink and target

Current
```
ls a_symlink                                                                                                                                                                                ╭───┬────────┬──────┬──────┬──────────────╮
│ # │  name  │ type │ size │   modified   │
├───┼────────┼──────┼──────┼──────────────┤
│ 0 │ a_file │ file │  0 B │ 20 hours ago │
╰───┴────────┴──────┴──────┴──────────────╯
```
With fix
```
ls a_symlink                                                                                                                                                                                ╭───┬───────────┬─────────┬──────┬──────────────╮
│ # │   name    │  type   │ size │   modified   │
├───┼───────────┼─────────┼──────┼──────────────┤
│ 0 │ a_symlink │ symlink │  6 B │ 20 hours ago │
╰───┴───────────┴─────────┴──────┴──────────────╯
```

## List existing symlink with missing target

Current
```
ls symfile_x                                                                                                                                                                          
Error: nu:🐚:directory_not_found (link)

  × Directory not found
   ╭─[entry #13:1:1]
 1 │ ls symfile_x
   ·    ────┬────
   ·        ╰── directory not found
   ╰────
```

With fix
```
ls symfile_x                                                                                                                                                                          ╭───┬───────────┬─────────┬──────┬─────────────╮
│ # │   name    │  type   │ size │  modified   │
├───┼───────────┼─────────┼──────┼─────────────┤
│ 0 │ symfile_x │ symlink │  6 B │ 2 hours ago │
╰───┴───────────┴─────────┴──────┴─────────────╯
```
2023-03-20 11:04:47 -05:00
Máté FARKAS
7d963776a0
stdlib: Implement common assert commands (#8515)
Implement common assert commands with tests.
Fixes #8419.

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-20 08:57:28 -05:00
JT
ecc153cbef
Fix command missing hook default config (#8540)
# Description

Unbreak unit tests by updating default config for the new hook that
landed after the syntax change but didn't get its tests re-run.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-20 11:18:30 +01:00
Antoine Stevan
d1309a36b2
standard library: fix the readme (#8526)
# Description
as we now want to put all the library in `std.nu` alone, this PR removes
the mentions to "creating a separate submodule from `std.nu`" from the
`README` of the standard library and adds a few clarifications about the
structure of the library.

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-03-20 17:05:49 +13:00
Steven Xu
1d3f6105f5
feat: add a command_not_found hook (#8314)
# Description
Add a `command_not_found` function to `$env.config.hooks`. If this
function outputs a string, then it's included in the `help`.

An example hook on *Arch Linux*, to find packages that contain the
binary, looks like:

```nushell
let-env config = {
  # ...
  hooks: {
    command_not_found: {
      |cmd_name| (
        try {
          let pkgs = (pkgfile --binaries --verbose $cmd_name)
          (
            $"(ansi $env.config.color_config.shape_external)($cmd_name)(ansi reset) " +
            $"may be found in the following packages:\n($pkgs)"
          )
        } catch {
          null
        }
      )
    }
    # ...
```

# User-Facing Changes
- Add a `command_not_found` function to `$env.config.hooks`.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-20 17:05:22 +13:00
Michael Angerman
64f50a179e
remove unused imports: Deserialize, Serialize compiler warning for nu-protocol/src/example.rs (#8514)
when running the tests inside nu-protocol we were getting a compiler
warning...
this PR removes the compiler warning from nu-protocol.
by adding
```rust
#[allow(unused_imports)]
```
2023-03-18 11:45:12 -07:00
Antoine Stevan
f9cf1d943c
standard library: use the standard assert and fix test output (#8509)
# Description
## in the `test_dirs` test module
- use the `std assert` function in the `test_dirs` module instead of
`myassert`
- refactor the "test cleaning" in the `clean` command
- allows to clean the tests and then throw a real error in the `catch`
block in case there is an error
- the test still "try"s to `clean` the test directory after the `catch`,
like in a "finally" block
- parse the `catch` error and `error make` a proper one instead of
`debug`ging it => because the `catch` will be triggered as soon as one
error occurs, there will always only be a single error in the tests, so
this does not change the behaviour of failing `dirs` tests!

> **Note**
> i'm not particularly happy with the parsing stage in the `catch`
block.
> however that's the simplest i found to both keep the `try` / `catch`
construct that allows to clean the test directory and have a proper
error at the same time!

## in the global `tests` module
- use `print` instead of `echo` to make sure the log statements show up
during the tests

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
```bash
nu crates/nu-utils/standard_library/tests.nu
```
passes but now with
- proper log statements
- proper error when a `dirs` error occurs => try with `sd 'assert \(1'
"assert (10" crates/nu-utils/standard_library/test_dirs.nu` 😉

# After Submitting
```
$nothing
```
2023-03-18 09:23:41 -05:00
Máté FARKAS
10a42de64f
standard library: add log commands (#8448)
# Description

```nushell
log critical "this is a critical message"
log error "this is an error message"
log warning "this is a warning message"
log info "this is an info message"
log debug "this is a debug message"
```


![image](https://user-images.githubusercontent.com/282320/225071852-1ddf0e87-d12b-452d-9598-5122df7123ab.png)

# Tests + Formatting

Tests are written. To run automatically, #8443 needs to be merged before
or after this PR.

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-18 08:19:54 -05:00
Máté FARKAS
3f224db990
Make assert eq, assert ne consistent with ==, != operators (#8473)
fixes #8418

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-18 08:59:27 +13:00
Artemiy
491a9c019c
Revert "Hide 7925" (#8500)
Revert nushell/nushell#8359
Turn `[empty list]` on by default again
2023-03-18 08:58:13 +13:00
Dan Davison
77e9f8d7df
Short redirection syntax (#8503)
This one's pretty clear from the diff! It's more of a language design
discussion.
2023-03-18 08:57:37 +13:00
Antoine Stevan
14bf0b000e
standard library: fix the tests for the new closure parsing of 0.77.2 (#8504)
# Description
as closures now need to have explicit parameters, this PR adds the empty
`||` to the two closure of the `std match` test.

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
```
nu crates/nu-utils/standard_library/tests.nu
```
does not give the following anymore
```
Error: nu::parser::closure_missing_pipe

  × Missing || inside closure
    ╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/test_std.nu:29:1]
 29 │     let branches = {
 30 │         1: { -1 }
    ·            ───┬──
    ·               ╰── Parsing as a closure, but || is missing
 31 │         2: { -2 }
    ╰────
  help: Try add || to the beginning of closure

Error: nu:🐚:only_supports_this_input_type

  × Input type not supported.
    ╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:7:1]
  7 │             nu -c $'use ($test_file) *; $nu.scope.commands | to nuon'
  8 │             | from nuon
    ·               ────┬────
    ·                   ╰── input type: nothing
  9 │             | where module_name == $module_name
    ·               ──┬──
    ·                 ╰── only list, binary, raw data or range input data is supported
 10 │             | where ($it.name | str starts-with "test_")
    ╰────
```

# After Submitting
```
$nothing
```
2023-03-18 08:52:08 +13:00
JT
0ca49091c0
Add rest and glob support to 'open' (#8506)
# Description

This adds two different features to `open`:
* The ability to pass more than one file to `open`.
* Support for using globs in the filenames

`open` will create a list stream and stream the output if there is more
than one file opened

Examples:

```
open file1.csv file2.csv file3.csv
```

```
open *.nu | where $it =~ "echo"
```

# User-Facing Changes

Multi-file and glob support in `open`. Original `open` functionality
should continue as before.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-18 08:51:39 +13:00
Antoine Stevan
bb8949f2b2
REFACTOR: put all the standard library in std.nu (#8489)
> **Warning**
> this PR is the result of a demand from the core team, to have the
simplest structure for the standard library, at least for now 👍

# Description
this PR mainly
- moved the `dirs.nu` module to the end of `std.nu`
- fixed the imports in `test_dirs.nu`

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
with the new runner from #8443, we get as expected 👌 
```
>_ nu crates/nu-utils/standard_library/tests.nu
INFO  Run tests in test_dirs
DEBUG Run test test_dirs/test_dirs_command
INFO  Run tests in test_std
DEBUG Run test test_std/test_assert
DEBUG Run test test_std/test_match
DEBUG Run test test_std/test_path_add
```

# After Submitting
```
$nothing
```
2023-03-17 12:30:35 -05:00
Darren Schroeder
ef7fbf4bf9
Revert "Allow NU_LIBS_DIR and friends to be const" (#8501)
Reverts nushell/nushell#8310

In anticipation that we may want to revert this PR. I'm starting the
process because of this issue.

This stopped working
```
let-env NU_LIB_DIRS = [
    ($nu.config-path | path dirname | path join 'scripts')
    'C:\Users\username\source\repos\forks\nu_scripts'
    ($nu.config-path | path dirname)
]
```
You have to do this now instead.
```
const NU_LIB_DIRS = [
    'C:\Users\username\AppData\Roaming\nushell\scripts'
    'C:\Users\username\source\repos\forks\nu_scripts'
    'C:\Users\username\AppData\Roaming\nushell'
]
```

In talking with @kubouch, he was saying that the `let-env` version
should keep working. Hopefully it's a small change.
2023-03-17 09:33:24 -05:00
WindSoilder
eb2e2e6370
make else if generate helpful error when condition have an issue (#8274)
# Description

Fixes: #7575

# User-Facing Changes

Previously:
```
if❯ if false { "aaa" } else if $a { 'a' }
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #10:1:1]
 1 │ if false { "aaa" } else if $a { 'a' }
   ·                         ─┬
   ·                          ╰── expected block, closure or record
   ╰────

```

After:
```
❯ if false { "aaa" } else if $a { 'a' }
Error: nu::parser::variable_not_found

  × Variable not found.
   ╭─[entry #1:1:1]
 1 │ if false { "aaa" } else if $a { 'a' }
   ·                            ─┬
   ·                             ╰── variable not found
   ╰────

```


# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-17 07:37:59 -05:00
WindSoilder
a8eef9af33
Restrict closure expression to be something like {|| ...} (#8290)
# Description

As title, closes: #7921 closes: #8273

# User-Facing Changes

when define a closure without pipe, nushell will raise error for now:
```
❯ let x = {ss ss}
Error: nu::parser::closure_missing_pipe

  × Missing || inside closure
   ╭─[entry #2:1:1]
 1 │ let x = {ss ss}
   ·         ───┬───
   ·            ╰── Parsing as a closure, but || is missing
   ╰────
  help: Try add || to the beginning of closure
```

`any`, `each`, `all`, `where` command accepts closure, it forces user
input closure like `{||`, or parse error will returned.
```
❯ {major:2, minor:1, patch:4} | values | each { into string }
Error: nu::parser::closure_missing_pipe

  × Missing || inside closure
   ╭─[entry #4:1:1]
 1 │ {major:2, minor:1, patch:4} | values | each { into string }
   ·                                             ───────┬───────
   ·                                                    ╰── Parsing as a closure, but || is missing
   ╰────
  help: Try add || to the beginning of closure
```

`with-env`, `do`, `def`, `try` are special, they still remain the same,
although it says that it accepts a closure, but they don't need to be
written like `{||`, it's more likely a block but can capture variable
outside of scope:
```
❯ def test [input] { echo [0 1 2] | do { do { echo $input } } }; test aaa
aaa
```

Just realize that It's a big breaking change, we need to update config
and scripts...

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-17 07:36:28 -05:00
StevenDoesStuffs
400a9d3b1e
Allow NU_LIBS_DIR and friends to be const (#8310)
# Description

Allow NU_LIBS_DIR and friends to be const they can be updated within the
same parse pass. This will allow us to remove having multiple config
files eventually.

Small implementation detail: I've changed `call.parser_info` to a
hashmap with string keys, so the information can have names rather than
indices, and we don't have to worry too much about the order in which we
put things into it.

Closes https://github.com/nushell/nushell/issues/8422

# User-Facing Changes

In a single file, users can now do stuff like
```
const NU_LIBS_DIR = ['/some/path/here']
source script.nu
```
and the source statement will use the value of NU_LIBS_DIR declared the
line before.

Currently, if there is no `NU_LIBS_DIR` const, then we fallback to using
the value of the `NU_LIBS_DIR` env-var, so there are no breaking changes
(unless someone named a const NU_LIBS_DIR for some reason).


![2023-03-04-014103_hyprshot](https://user-images.githubusercontent.com/13265529/222885263-135cdd0d-7884-438b-b2ed-c3979fa44463.png)

# Tests + Formatting

~~TODO: write tests~~ Done

# After Submitting

~~TODO: update docs~~ Will do when we update default_env.nu/merge
default_env.nu into default_config.nu.
2023-03-17 07:23:29 -05:00
Luc Perkins
7095d8994e
Add char --list example to char command docs (#8474)
# Description

When using `char`, I somehow missed the `--list` flag (even though it's
of course displayed in the help output). While it's maybe a bit
redundant to have a usage of the flag in the examples, I suspect that I
may not be alone in needing an extra nudge on getting that info 😄

# User-Facing Changes

Just an extra example in the `char` help output.
2023-03-17 10:15:41 +01:00
JT
2d41613039
bump to 0.77.2 (#8496)
# 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.)_

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-17 21:29:15 +13:00
JT
1552eb921a
parser: Add cell path literal syntax (#8493)
# Description

This adds a new cell path literal syntax for use in any value position,
not just in a context where we expect a cell path.

This can be used to assign to a variable and then later use that
variable as a cell path.

Example:
```
> let cell_path = $.a.b
> {a: {b: 3}} | get $cell_path
3
```
# User-Facing Changes

This adds the syntax `$.a.b` to universally mean the cell path `a.b`,
even in a context that doesn't expect a cell path.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-17 15:19:41 +13:00
JT
0ac3f7a1c8
parser: Fix panic that happens when you type a single { (#8492)
# Description

Fix the recent parser panic with a single `{`

Introduced by https://github.com/nushell/nushell/pull/8470

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-17 15:19:23 +13:00
Dan Davison
7625aed200
SQL-style join command for Nushell tables (#8424)
This PR adds a command `join` for performing SQL-style joins on Nushell
tables:

```
〉join -h
Join two tables

Usage:
  > join {flags} <right-table> <left-on> (right-on)

Flags:
  -h, --help - Display the help message for this command
  -i, --inner - Inner join (default)
  -l, --left - Left-outer join
  -r, --right - Right-outer join
  -o, --outer - Outer join

Signatures:
  <table> | join list<any>, <string>, <string?> -> <table>

Parameters:
  right-table <list<any>>: The right table in the join
  left-on <string>: Name of column in input (left) table to join on
  (optional) right-on <string>: Name of column in right table to join on. Defaults to same column as left table.

Examples:
  Join two tables
  > [{a: 1 b: 2}] | join [{a: 1 c: 3}] a
  ╭───┬───┬───╮
  │ a │ b │ c │
  ├───┼───┼───┤
  │ 1 │ 2 │ 3 │
  ╰───┴───┴───╯
```

<table>
    <tbody>
        <tr>
<td><img width="400" alt="image"
src="https://user-images.githubusercontent.com/52205/224578744-eb9d133e-2510-4a3d-bd0a-d615f07a06b7.png"></td>
        </tr>
    </tbody>
  </table>


# User-Facing Changes

Adds a new command `join`

# Tests + Formatting

```
cargo test -p nu-command commands::join
```

Don't forget to add tests that cover your changes.

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass

# 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: Reilly Wood <reilly.wood@icloud.com>
2023-03-16 16:57:20 -07:00
Artemiy
19beafa865
Disable pipeline echo (#8292)
# Description

Change behavior of block evaluation to not print result of intermediate
commands.
Previously result of every but last pipeline in a block was printed to
stdout, and last one was returned

![image](https://user-images.githubusercontent.com/17511668/222550110-3f62fbed-432c-4b46-b9b1-4cb45a1f893e.png)
With this change results of intermediate pipelines are discarded after
they finish and the last one is returned as before:

![image](https://user-images.githubusercontent.com/17511668/222550346-f1e74f80-f6b6-4aa3-98d6-888ea4cb4915.png)
Now one should use `print` explicitly to print something to stdout

![image](https://user-images.githubusercontent.com/17511668/222923955-fda0d77b-41b4-4f91-a80f-12b0a1880c05.png)

**Note, that this behavior is not limited to functions!** The scope of
this change are all blocks. All of the below are executed as blocks and
thus exibited this behavior in the same way:

![image](https://user-images.githubusercontent.com/17511668/222924062-342c15de-4273-4bf5-8b39-fe6e3aa96076.png)

With this change outputs for all types of blocks are cleaned:

![image](https://user-images.githubusercontent.com/17511668/222924118-7d51c27e-04bb-43e5-8efe-38b484683bfe.png)


# User-Facing Changes

All types of blocks (function bodies, closures, `if` branches, `for` and
`loop` bodies e.t.c.) no longer print result of intermediate pipelines.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-17 11:53:46 +13:00
Matthew Deville
8543b0789d
Additional flags for commands from csv and from tsv (#8398)
# Description

Resolves issue #8370

Adds the following flags to commands `from csv` and `from tsv`:
- `--flexible`: allow the number of fields in records to be variable
- `-c --comment`: a comment character to ignore lines starting with it
- `-q --quote`: a quote character to ignore separators in strings,
defaults to '\"'
- `-e --escape`: an escape character for strings containing the quote
character

Internally, the `Value` struct has an additional helper function
`as_char` which converts it to a single `char`

# User-Facing Changes

The single quoted string `'\t'` can no longer be used as a parameter for
the flag `--separator '\t'` as it is interpreted as a two-character
string. One needs to use from now on the flag with a double quoted
string like so: `-s "\t"` which correctly interprets the string as a
single `char`.
2023-03-16 17:49:46 -05:00
Darren Schroeder
bdaa01165e
enable error reporting from enable_vt_processing (#8373)
# Description

This PR tweaks the enable_vt_processing() function with more verbose
error handling. This is related to #8344.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-16 17:48:21 -05:00
Steven Xu
b2a557d4ed
fix: fix commandline when called with no arguments (#8207)
# Description

This fixes the `commandline` command when it's run with no arguments, so
it outputs the command being run. New line characters are included.

This allows for:

- [A way to get current command inside pre_execution hook · Issue #6264
· nushell/nushell](https://github.com/nushell/nushell/issues/6264)
- The possibility of *Atuin* to work work *Nushell*. *Atuin* hooks need
to know the current repl input before it is run.

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-16 17:45:35 -05:00
JT
0903a891e4
Fix parse of def with paren params (#8490)
# Description

This adds back support for parens around params, eg `def foo (x: int) {
... }`

# User-Facing Changes

returns to the original support before the recent parser refactor

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-17 09:08:41 +13:00
Reilly Wood
1b2916988e
Add -i flag back to get and select (#8488)
https://github.com/nushell/nushell/pull/8379 removed the `-i` flag from
`get` and `select` because the new `?` functionality covers most of the
same use cases. However, https://github.com/nushell/nushell/issues/8480
made me realize that `-i` is still useful when dealing with cell paths
in variables.

This PR re-adds the `-i` flag to `get` and `select`. It works by just
marking every member in the cell path as optional, which will behave
_slightly_ differently than `-i` used to (previously it would suppress
any errors, even type errors) but IMO that's OK.
2023-03-16 11:50:04 -07:00
Máté FARKAS
d74a260883
stdlib: add test discovery, extract test files (#8443)
# Description

Was original asked here:
https://github.com/nushell/nushell/pull/8405#issuecomment-1465062652
Make it easier to extend standard library with submodules.
(For a new submodule called `xx.nu` the tests can be written in
`test_xx.nu`).
Test discovery is implemented.

# User-Facing Changes

There are no user-facing changes.

# Tests + Formatting

Tests are updated.
There is no `nufmt` now.

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-16 13:23:29 -05:00
WindSoilder
31d9c0889c
Revert "Throw out error if external command in subexpression is failed to run (#8204)" (#8475)
This reverts commit dec0a2517f.

It breaks programs like `fzf`

# Description

Fixes: #8472 
Fixes:  #8313
Reopen: #7690 

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-17 07:07:32 +13:00
JT
222c0f11c3
Escape will now escape paths with '=' in them (#8485)
# Description

Fixes the issue where there is no way to escape `FOO=BAR` in a way that
treats it as a file path/executable name. Previously `^FOO=BAR` would be
handled as an environment shorthand. Now, environment shorthands are not
allowed to start with `^`. To create an environment shorthand value that
uses `^` as the first character of the environment variable name, use
quotes, eg `"^FOO"=BAR`

# User-Facing Changes

This should enable `=` being in paths and external command names in
command position.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-17 07:05:08 +13:00
NitinL
106ca65c58
Added fix for bug #8278 to read tag values from YAML files (#8354)
# Description

This PR adds a fix for reading tag values from YAML file.

A tag in YAML file is denoted by using the exclamation point ("!")
symbol.

For example - Key: !Value

Additional passing test has also been added supporting the bug fix - 
- `test_convert_yaml_value_to_nu_value_for_tagged_values`

The fix passes all the below required tests suites locally - 

>To check standard code formatting.
- `cargo fmt --all -- --check` (`cargo fmt --all` applies these changes)
>To check that you're using the standard code style.
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect`
>To check that all tests pass
- `cargo test --workspace`

---------

Co-authored-by: Nitin Londhe <nitin.londhe@genmills.com>
2023-03-16 09:50:30 -05:00
Justin Ma
e672689a76
Fix docs building error caused by missing end tag (#8477) 2023-03-16 19:41:19 +08:00
dependabot[bot]
2579a827fc
Bump mockito from 0.32.5 to 1.0.0 (#8426)
Bumps [mockito](https://github.com/lipanski/mockito) from 0.32.5 to
1.0.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/lipanski/mockito/releases">mockito's
releases</a>.</em></p>
<blockquote>
<h2>1.0.0</h2>
<p>🎈 7 years and 63 releases later, it's finally time for the
1.0 🎈</p>
<h2>Changes</h2>
<ul>
<li><strong>[Breaking]</strong> The legacy interface was removed in this
version</li>
<li><strong>[Breaking]</strong> <code>Mock::with_body_from_fn</code> was
renamed to <code>Mock::with_chunked_body</code> - the former is still
supported with a deprecation warning</li>
<li>Mocks are only cleared when the server is dropped, not when the mock
is dropped - this means you <strong>don't have to assign mocks to
variables any more</strong> (unless you want to call other methods on
them)</li>
<li>Introduced the <code>Mock::remove</code> and
<code>Mock::remove_async</code> methods to remove mocks on demand</li>
</ul>
<h2>Major changes since 0.31</h2>
<ul>
<li>Tests can now run in parallel</li>
<li>Support for HTTP2</li>
<li>An async interface for all actions (though the sync interface is
also available)</li>
<li>Mock multiple server/hosts at the same time</li>
</ul>
<p>For a list of all the changes please check the <a
href="https://github.com/lipanski/mockito/releases">release log</a>.</p>
<h2>Migrating to the new API</h2>
<p>Legacy API:</p>
<pre lang="rust"><code>let m1 = mockito::mock(&quot;GET&quot;,
&quot;/hello&quot;).with_body(&quot;hello&quot;).create();
let m2 = mockito::mock(&quot;GET&quot;,
&quot;/bye&quot;).with_body(&quot;bye&quot;).create();
<p>// Use one of these to configure your client
let host = mockito:server_address();
let url = mockito::server_url();
</code></pre></p>
<p>New API:</p>
<pre lang="rust"><code>let mut server = mockito::Server::new();
server.mock(&quot;GET&quot;,
&quot;/hello&quot;).with_body(&quot;hello&quot;).create();
server.mock(&quot;GET&quot;,
&quot;/bye&quot;).with_body(&quot;bye&quot;).create();
<p>// Use one of these to configure your client
let host = server.host_with_port();
let url = server.url();
</code></pre></p>
<blockquote>
<p>If you can't migrate to the new API in one go, consider using version
0.32.5, which supports both the legacy API as well as the new API.</p>
</blockquote>
<h2>Migrating to the async API</h2>
<p>In order to write async tests, you'll need to use the
<code>_async</code> methods:</p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="9a07811955"><code>9a07811</code></a>
Bump to 1.0.0</li>
<li><a
href="000c435f0e"><code>000c435</code></a>
Merge pull request <a
href="https://redirect.github.com/lipanski/mockito/issues/165">#165</a>
from lipanski/one-zero</li>
<li><a
href="68c56290a1"><code>68c5629</code></a>
Remove mocks when the server is dropped, not when the mock is
dropped</li>
<li><a
href="ac9042d022"><code>ac9042d</code></a>
Add the Windows line-ending fix to the test runner</li>
<li><a
href="0ce9788e00"><code>0ce9788</code></a>
Disable color tests on Windows</li>
<li><a
href="ad2ebcbaab"><code>ad2ebcb</code></a>
Fine-tuning the Windows test runner</li>
<li><a
href="abb9e91d71"><code>abb9e91</code></a>
Run Windows tests on Github Actions</li>
<li><a
href="5a7c96eaec"><code>5a7c96e</code></a>
Rename Mock::with_body_from_fn to Mock::with_chunked_body</li>
<li><a
href="ed338faedf"><code>ed338fa</code></a>
Uncomment threads tests</li>
<li><a
href="6e2064de95"><code>6e2064d</code></a>
Drop legacy interface</li>
<li>Additional commits viewable in <a
href="https://github.com/lipanski/mockito/compare/0.32.5...1.0.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=mockito&package-manager=cargo&previous-version=0.32.5&new-version=1.0.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 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>
2023-03-16 11:40:49 +01:00
Nicolas Kosinski
8c487edf62
docs: Use capital letters for CSV and JSON acronyms (#8459)
Capital letters matter! 😉 
<img width="927" alt="Screenshot 2023-03-15 at 06 54 22"
src="https://user-images.githubusercontent.com/3862051/225219635-cfde7c3b-66c1-40a5-87f5-0d1a5d41955e.png">

See https://github.com/nushell/nushell.github.io/pull/827/files that was
created before this one.
2023-03-15 21:52:13 -07:00
WindSoilder
0b97f52a8b
make better usage of error value in catch block (#8460)
# Description

Fixes: #8402  #8391

The cause of these issue if when we want to evaluate a expression with
`Value::Error`, nushell show error immediately. To fix the issue, we can
wrap the `Value::Error` into a `Value::Record`. So user can see the
message he want.

# User-Facing Changes

Before
```
❯ try { 1 / 0 } catch {|e| echo $"error is ($e)"}
Error: nu:🐚:division_by_zero

  × Division by zero.
   ╭─[entry #2:1:1]
 1 │ try { 1 / 0 } catch {|e| echo $"error is ($e)"}
   ·         ┬
   ·         ╰── division by zero
   ╰────
```

After
```
❯ try { 1 / 0 } catch {|e| echo $"error is ($e)"}
error is {msg: Division by zero., debug: DivisionByZero { span: Span { start: 43104, end: 43105 } }, raw: DivisionByZero { sp
an: Span { start: 43104, end: 43105 } }}
```

As we can see, error becomes a record with `msg`, `debug`, `raw`
columns.
1. msg column is a user friendly message.
2. debug column is more about `Value::Error` information as a string.
3. raw column is a `Value::Error` itself, if user want to re-raise the
error, just use `$e | get raw`

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-15 20:56:18 -07:00
Reilly Wood
21b84a6d65
Optional members in cell paths: Attempt 2 (#8379)
This is a follow up from https://github.com/nushell/nushell/pull/7540.
Please provide feedback if you have the time!

## Summary

This PR lets you use `?` to indicate that a member in a cell path is
optional and Nushell should return `null` if that member cannot be
accessed.

Unlike the previous PR, `?` is now a _postfix_ modifier for cell path
members. A cell path of `.foo?.bar` means that `foo` is optional and
`bar` is not.

`?` does _not_ suppress all errors; it is intended to help in situations
where data has "holes", i.e. the data types are correct but something is
missing. Type mismatches (like trying to do a string path access on a
date) will still fail.

### Record Examples

```bash

{ foo: 123 }.foo # returns 123

{ foo: 123 }.bar # errors
{ foo: 123 }.bar? # returns null

{ foo: 123 } | get bar # errors
{ foo: 123 } | get bar? # returns null

{ foo: 123 }.bar.baz # errors
{ foo: 123 }.bar?.baz # errors because `baz` is not present on the result from `bar?`
{ foo: 123 }.bar.baz? # errors
{ foo: 123 }.bar?.baz? # returns null
```

### List Examples
```
〉[{foo: 1} {foo: 2} {}].foo
Error: nu:🐚:column_not_found

  × Cannot find column
   ╭─[entry #30:1:1]
 1 │ [{foo: 1} {foo: 2} {}].foo
   ·                    ─┬  ─┬─
   ·                     │   ╰── cannot find column 'foo'
   ·                     ╰── value originates here
   ╰────
〉[{foo: 1} {foo: 2} {}].foo?
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │   │
╰───┴───╯
〉[{foo: 1} {foo: 2} {}].foo?.2 | describe
nothing

〉[a b c].4? | describe
nothing

〉[{foo: 1} {foo: 2} {}] | where foo? == 1
╭───┬─────╮
│ # │ foo │
├───┼─────┤
│ 0 │   1 │
╰───┴─────╯
```

# Breaking changes

1. Column names with `?` in them now need to be quoted.
2. The `-i`/`--ignore-errors` flag has been removed from `get` and
`select`
1. After this PR, most `get` error handling can be done with `?` and/or
`try`/`catch`.
4. Cell path accesses like this no longer work without a `?`:
```bash
〉[{a:1 b:2} {a:3}].b.0
2
```
We had some clever code that was able to recognize that since we only
want row `0`, it's OK if other rows are missing column `b`. I removed
that because it's tricky to maintain, and now that query needs to be
written like:


```bash
〉[{a:1 b:2} {a:3}].b?.0
2
```

I think the regression is acceptable for now. I plan to do more work in
the future to enable streaming of cell path accesses, and when that
happens I'll be able to make `.b.0` work again.
2023-03-15 20:50:58 -07:00
Antoine Stevan
d3be5ec750
DOC: make the README of the standard library clearer (#8465)
Should close #8444.

# Description
as asked by @presidento, i've used a generic command to run the tests.

i've also transformed the "a concrete example" sections into quote
blocks to make them stand out less.
not sure about that one, please tell me what you think 😋 

i think a small example is always helpfull, maybe some work has to be
done to make it better 💪

# User-Facing Changes
hopefully a slightly clearer README for the standard library

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-03-15 20:13:09 -07:00
Jakub Žádník
4b16406050
Add proptest regression (#8396)
# Description

I found this when I was checking out my commits. It must have happened
during one of the random test failures that I've been getting quite
often recently.

# User-Facing Changes

None?

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-15 20:08:02 -07:00
JT
b0ce602e4b
Start grouping parsing of values better (#8470)
# Description

This starts working on refactoring the parser to no longer use
SyntaxShape when making parsing decisions about values. This PR covers
grouping a few of the steps in `parse_value` to key off the first
character for what group of parsing steps it should use.

# User-Facing Changes

Hopefully none.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-16 16:06:43 +13:00
dependabot[bot]
aa876ce24f
Bump lru from 0.9.0 to 0.10.0 (#8425) 2023-03-15 18:47:40 +00:00
dependabot[bot]
71fdf717a8
Bump open from 3.4.0 to 4.0.0 (#8427) 2023-03-15 18:41:39 +00:00
Klementiev Dmitry
4de0347fdc
Added help externs command (#8403)
# Description

`help externs` - command, which list external commands

Closes https://github.com/nushell/nushell/issues/8301

# User-Facing Changes

```nu
$ help externs
╭───┬──────────────┬─────────────┬───────────────────────────────────────────────────╮
│ # │     name     │ module_name │                       usage                       │
├───┼──────────────┼─────────────┼───────────────────────────────────────────────────┤
│ 0 │ git push     │ completions │ Push changes                                      │
│   │              │             │                                                   │
│ 1 │ git fetch    │ completions │ Download objects and refs from another repository │
│   │              │             │                                                   │
│ 2 │ git checkout │ completions │ Check out git branches and files                  │
│   │              │             │                                                   │
╰───┴──────────────┴─────────────┴───────────────────────────────────────────────────╯
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-15 18:40:27 +01:00
dependabot[bot]
f34ac9be62
Bump sqlparser from 0.30.0 to 0.32.0 (#8428)
Bumps [sqlparser](https://github.com/sqlparser-rs/sqlparser-rs) from
0.30.0 to 0.32.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/sqlparser-rs/sqlparser-rs/blob/main/CHANGELOG.md">sqlparser's
changelog</a>.</em></p>
<blockquote>
<h2>[0.32.0] 2023-03-6</h2>
<h3>Added</h3>
<ul>
<li>Support ClickHouse <code>CREATE TABLE</code> with <code>ORDER
BY</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/824">#824</a>)
- Thanks <a
href="https://github.com/ankrgyl"><code>@​ankrgyl</code></a></li>
<li>Support PostgreSQL exponentiation <code>^</code> operator (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/813">#813</a>)
- Thanks <a
href="https://github.com/michael-2956"><code>@​michael-2956</code></a></li>
<li>Support <code>BIGNUMERIC</code> type in BigQuery (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/811">#811</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
<li>Support for optional trailing commas (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/810">#810</a>)
- Thanks <a
href="https://github.com/ankrgyl"><code>@​ankrgyl</code></a></li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Fix table alias parsing regression by backing out redshift column
definition list (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/827">#827</a>)
- Thanks <a
href="https://github.com/alamb"><code>@​alamb</code></a></li>
<li>Fix typo in <code>ReplaceSelectElement</code>
<code>colum_name</code> --&gt; <code>column_name</code> (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/822">#822</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
</ul>
<h2>[0.31.0] 2023-03-1</h2>
<h3>Added</h3>
<ul>
<li>Support raw string literals for BigQuery dialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/812">#812</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
<li>Support <code>SELECT * REPLACE &lt;Expr&gt; AS
&lt;Identifier&gt;</code> in BigQuery dialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/798">#798</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
<li>Support byte string literals for BigQuery dialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/802">#802</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
<li>Support columns definition list for system information functions in
RedShift dialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/769">#769</a>)
- Thanks <a
href="https://github.com/mskrzypkows"><code>@​mskrzypkows</code></a></li>
<li>Support <code>TRANSIENT</code> keyword in Snowflake dialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/807">#807</a>)
- Thanks <a
href="https://github.com/mobuchowski"><code>@​mobuchowski</code></a></li>
<li>Support <code>JSON</code> keyword (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/799">#799</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
<li>Support MySQL Character Set Introducers (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/788">#788</a>)
- Thanks <a
href="https://github.com/mskrzypkows"><code>@​mskrzypkows</code></a></li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Fix clippy error in ci (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/803">#803</a>)
- Thanks <a
href="https://github.com/togami2864"><code>@​togami2864</code></a></li>
<li>Handle offset in map key in BigQuery dialect (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/797">#797</a>)
- Thanks <a
href="https://github.com/Ziinc"><code>@​Ziinc</code></a></li>
<li>Fix a typo (precendence -&gt; precedence) (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/794">#794</a>)
- Thanks <a
href="https://github.com/SARDONYX-sard"><code>@​SARDONYX-sard</code></a></li>
<li>use post_* visitors for mutable visits (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/789">#789</a>)
- Thanks <a
href="https://github.com/lovasoa"><code>@​lovasoa</code></a></li>
</ul>
<h3>Changed</h3>
<ul>
<li>Add another known user (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/787">#787</a>)
- Thanks <a
href="https://github.com/joocer"><code>@​joocer</code></a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="5f815c2b08"><code>5f815c2</code></a>
(cargo-release) version 0.32.0</li>
<li><a
href="1d358592ab"><code>1d35859</code></a>
Changelog for 0.32.0 (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/830">#830</a>)</li>
<li><a
href="7f4c9132d7"><code>7f4c913</code></a>
Fix table alias parsing regression in 0.31.0 by backing out redshift
column d...</li>
<li><a
href="d69b875367"><code>d69b875</code></a>
ClickHouse CREATE TABLE Fixes: add ORDER BY and fix clause ordering (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/824">#824</a>)</li>
<li><a
href="1cf913e717"><code>1cf913e</code></a>
feat: Support PostgreSQL exponentiation. (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/813">#813</a>)</li>
<li><a
href="fbbf1a4e84"><code>fbbf1a4</code></a>
feat: support <code>BIGNUMERIC</code> of bigquery (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/811">#811</a>)</li>
<li><a
href="b45306819c"><code>b453068</code></a>
Add support for trailing commas (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/810">#810</a>)</li>
<li><a
href="2285bb44ba"><code>2285bb4</code></a>
chore: fix typo (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/822">#822</a>)</li>
<li><a
href="b838415276"><code>b838415</code></a>
(cargo-release) version 0.31.0</li>
<li><a
href="66ec634c67"><code>66ec634</code></a>
Update CHANGELOG for version 0.31 (<a
href="https://redirect.github.com/sqlparser-rs/sqlparser-rs/issues/820">#820</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/sqlparser-rs/sqlparser-rs/compare/v0.30.0...v0.32.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sqlparser&package-manager=cargo&previous-version=0.30.0&new-version=0.32.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)

---

**Note:** Dependabot was ignoring updates to this dependency, but since
you've updated it yourself we've started tracking it for you again. 🤖

<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 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>
2023-03-15 18:33:09 +01:00
Máté FARKAS
12652f897a
std.nu: Rewrite assert method (#8405)
It is a common pattern to add message to assert.
Also the error message was not so helpful. (See the difference in the
documentation)

---------

Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
2023-03-15 18:19:38 +01:00
Hofer-Julian
24ee381fea
Fix xml docs (#8462)
See https://github.com/nushell/nushell.github.io/pull/828
2023-03-15 07:21:48 -05:00
Nicolas Kosinski
494a07f6f3
docs: Add missing space in Filesystem/start's usage (#8458)
In order to fix the selected text, below, in the documentation: 
<img width="1252" alt="Screenshot 2023-03-15 at 06 50 25"
src="https://user-images.githubusercontent.com/3862051/225218941-7654803f-7b85-490a-9fb0-3de7d666935b.png">

PS: see https://github.com/nushell/nushell.github.io/pull/826 that was
created before this pull request.
2023-03-15 07:16:41 -05:00
JT
61455b457d
Fix warnings and old names (#8457)
# Description

This fixes up some clippy warnings and removes some old names/info from
our unit tests

# User-Facing Changes

Internal changes only

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

> **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.
2023-03-15 18:54:55 +13:00
Reilly Wood
57ce6a7c66
Fix ls behaviour when directory is empty (#8439)
Prior to this PR, `ls` would return `nothing` in an empty directory.
After this PR, it returns an empty `List`. This makes the behaviour of
`ls` more consistent and easier to reason about (IMO).

This was prompted by a user noticing that `ls | where size == 0KB and
type == file` breaks when run in an empty directory:

```
  × Input type not supported.
   ╭─[entry #12:1:1]
 1 │ ls | where size == 0KB and type == file
   · ─┬   ──┬──
   ·  │     ╰── only list, binary, raw data or range input data is supported
   ·  ╰── input type: nothing
   ╰────
```

If people agree with this change, let's wait until after the 0.77
release so we have a bit more time to test it.
2023-03-15 18:31:07 +13:00
Thomas Coratger
0bd4d27e8d
Modify reject algorithm for identical elements (#8446)
# Description

The correction made here concerns the issue #8431. Indeed, the algorithm
initially proposed to remove elements of a `vector` performed a loop
with `remove` and an incident therefore appeared when several values
were equal because the deletion was done outside the length of the
vector:
```rust
let mut found = false;
for (i, col) in cols.clone().iter().enumerate() {
    if col == col_name {
        cols.remove(i);
        vals.remove(i);
        found = true;
    }
}

```

Then, `[[a, a]; [1, 2]] | reject a: ` gave `thread 'main' panicked at
'removal index (is 1) should be < len (is 1)',
crates/nu-protocol/src/value/mod.rs:1213:54`.

The proposed correction is therefore the implementation of the
`retain_mut` utility dedicated to this functionality.

```rust
let mut found = false;
let mut index = 0;
cols.retain_mut(|col| {
    if col == col_name {
        found = true;
        vals.remove(index);
        false
    } else {
        index += 1;
        true
    }
});
```
2023-03-14 23:26:48 +01:00
Stefan Holderbach
1701303279
Bump to 0.77.1 development version (#8453)
# Description

Either to be used in an emergency point release or to indicate
development builds in the `version` command
2023-03-14 23:26:08 +01:00
Stefan Holderbach
fd09609b44
Bump version to 0.77.0 (#8410) 2023-03-14 20:46:42 +02:00
Stefan Holderbach
c7583ecdb7
Pin to reedline 0.17 (#8441)
# Description

See release notes:

https://github.com/nushell/reedline/releases/tag/v0.17.0
2023-03-14 00:04:36 +01:00
Stefan Holderbach
4eec4a27c7
Pin to nu-ansi-term 0.47 (#8440)
# Description

Update reedline to a commit that uses the same version as we share types

# User-Facing Changes

(-)

# Tests + Formatting

Build check
2023-03-13 23:38:18 +01:00
BlacAmDK
86faf753bd
Fix SQLite table creation sql (#8430)
# Description

The "CREATE TABLE" statement in `into sqlite` does not add quotes to the
column names, reproduction steps are below:

```
/home/xxx〉[[name,y/n];[a,y]] | into sqlite test.db
Error: 
  × Failed to prepare SQLite statement
   ╭─[entry #1:1:1]
 1 │ [[name,y/n];[a,y]] | into sqlite test.db
   ·                                                       ───┬───
   ·                                                             ╰── near "/": syntax error in CREATE TABLE IF NOT EXISTS main (name TEXT,y/n TEXT) at offset 44
   ╰────
```

# User-Facing Changes

None

---------

Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
2023-03-13 10:11:28 -07:00
Stefan Holderbach
79d0735864
Remove unused nu-json from nu-protocol (#8417)
This dependency apears unnecessary and should remove a link in the crate
graph that could favor parallel compilation
2023-03-12 20:26:35 +01:00
Jakub Žádník
808e523adc
Disable alias recursion (#8397)
# Description

Prevents alias from aliasing itself. It allows a commonly requested
pattern similar to `alias ls = ls -l`.

One small issue is that the syntax highlighting is a bit off:

![alias_itself_no_color](https://user-images.githubusercontent.com/25571562/224545129-8a3ff535-347b-4a4e-b686-11493bb2a33b.png)

Fixes https://github.com/nushell/nushell/issues/8246

# User-Facing Changes

Shouldn't be a breaking change.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-13 06:16:26 +13:00
Stefan Holderbach
a52386e837
Box ShellError in Value::Error (#8375)
# Description

Our `ShellError` at the moment has a `std::mem::size_of<ShellError>` of
136 bytes (on AMD64). As a result `Value` directly storing the struct
also required 136 bytes (thanks to alignment requirements).

This change stores the `Value::Error` `ShellError` on the heap.

Pro:
- Value now needs just 80 bytes
- Should be 1 cacheline less (still at least 2 cachelines)

Con:
- More small heap allocations when dealing with `Value::Error`
  - More heap fragmentation
  - Potential for additional required memcopies

# Further code changes

Includes a small refactor of `try` due to a type mismatch in its large
match.

# User-Facing Changes

None for regular users.

Plugin authors may have to update their matches on `Value` if they use
`nu-protocol`

Needs benchmarking to see if there is a benefit in real world workloads.
**Update** small improvements in runtime for workloads with high volume
of values. Significant reduction in maximum resident set size, when many
values are held in memory.

# Tests + Formatting
2023-03-12 09:57:27 +01:00
dependabot[bot]
c26d91fb61
Bump nix from 0.25.0 to 0.26.2 (#8129)
Bumps [nix](https://github.com/nix-rust/nix) from 0.25.0 to 0.26.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/nix-rust/nix/blob/v0.26.2/CHANGELOG.md">nix's
changelog</a>.</em></p>
<blockquote>
<h2>[0.26.2] - 2023-01-18</h2>
<h3>Fixed</h3>
<ul>
<li>Fix <code>SockaddrIn6</code> bug that was swapping flowinfo and
scope_id byte ordering.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1964">#1964</a>)</li>
</ul>
<h2>[0.26.1] - 2022-11-29</h2>
<h3>Fixed</h3>
<ul>
<li>Fix UB with <code>sys::socket::sockopt::SockType</code> using
<code>SOCK_PACKET</code>.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1821">#1821</a>)</li>
</ul>
<h2>[0.26.0] - 2022-11-29</h2>
<h3>Added</h3>
<ul>
<li>Added <code>SockaddrStorage::{as_unix_addr, as_unix_addr_mut}</code>
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1871">#1871</a>)</li>
<li>Added <code>MntFlags</code> and <code>unmount</code> on all of the
BSDs.</li>
<li>Added <code>any()</code> and <code>all()</code> to
<code>poll::PollFd</code>.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1877">#1877</a>)</li>
<li>Add <code>MntFlags</code> and <code>unmount</code> on all of the
BSDs.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1849">#1849</a>)</li>
<li>Added a <code>Statfs::flags</code> method.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1849">#1849</a>)</li>
<li>Added <code>NSFS_MAGIC</code> FsType on Linux and Android.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1829">#1829</a>)</li>
<li>Added <code>sched_getcpu</code> on platforms that support it.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1825">#1825</a>)</li>
<li>Added <code>sched_getaffinity</code> and
<code>sched_setaffinity</code> on FreeBSD.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1804">#1804</a>)</li>
<li>Added <code>line_discipline</code> field to <code>Termios</code> on
Linux, Android and Haiku
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1805">#1805</a>)</li>
<li>Expose the memfd module on FreeBSD (memfd was added in FreeBSD 13)
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1808">#1808</a>)</li>
<li>Added <code>domainname</code> field of <code>UtsName</code> on
Android and Linux
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1817">#1817</a>)</li>
<li>Re-export <code>RLIM_INFINITY</code> from <code>libc</code>
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1831">#1831</a>)</li>
<li>Added <code>syncfs(2)</code> on Linux
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1833">#1833</a>)</li>
<li>Added <code>faccessat(2)</code> on illumos
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1841">#1841</a>)</li>
<li>Added <code>eaccess()</code> on FreeBSD, DragonFly and Linux (glibc
and musl).
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1842">#1842</a>)</li>
<li>Added <code>IP_TOS</code> <code>SO_PRIORITY</code> and
<code>IPV6_TCLASS</code> sockopts for Linux
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1853">#1853</a>)</li>
<li>Added <code>new_unnamed</code> and <code>is_unnamed</code> for
<code>UnixAddr</code> on Linux and Android.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1857">#1857</a>)</li>
<li>Added <code>SockProtocol::Raw</code> for raw sockets
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1848">#1848</a>)</li>
<li>added <code>IP_MTU</code> (<code>IpMtu</code>)
<code>IPPROTO_IP</code> sockopt on Linux and Android.
(<a
href="https://github-redirect.dependabot.com/nix-rust/nix/pull/1865">#1865</a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="1e3f062fd8"><code>1e3f062</code></a>
(cargo-release) version 0.26.2</li>
<li><a
href="013931b68f"><code>013931b</code></a>
Merge <a
href="https://github-redirect.dependabot.com/nix-rust/nix/issues/1974">#1974</a></li>
<li><a
href="8aa85bbf27"><code>8aa85bb</code></a>
fix: clippy::size_of_ref</li>
<li><a
href="4a83f8b8b5"><code>4a83f8b</code></a>
Drop x86_64-unknown-darwin to Tier 2</li>
<li><a
href="975a3d5c7c"><code>975a3d5</code></a>
Tidy up the CHANGELOG a bit.</li>
<li><a
href="6fd7418158"><code>6fd7418</code></a>
Fix endian swap on SocketAddrV6.</li>
<li><a
href="e7a646ddff"><code>e7a646d</code></a>
(cargo-release) version 0.26.1</li>
<li><a
href="749bf755ce"><code>749bf75</code></a>
Merge <a
href="https://github-redirect.dependabot.com/nix-rust/nix/issues/1821">#1821</a></li>
<li><a
href="8e91b28b64"><code>8e91b28</code></a>
Fix UB in the SO_TYPE sockopt</li>
<li><a
href="12fb35434f"><code>12fb354</code></a>
[skip ci] add a CHANGELOG section for the next release</li>
<li>Additional commits viewable in <a
href="https://github.com/nix-rust/nix/compare/v0.25.0...v0.26.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=nix&package-manager=cargo&previous-version=0.25.0&new-version=0.26.2)](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 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>
2023-03-12 09:03:02 +01:00
Artemiy
a13946e3ef
New xml format (#7947)
# Description

Changes old `from xml` `to xml` data formats. See #7682 for reasoning
behind this change.
Output is now a series of records with `tag`, `attributes` and `content`
fields.

Old:

![image](https://user-images.githubusercontent.com/17511668/224508728-92d37c1f-ebac-4d5c-924d-bebd60f5cf85.png)
New:

![image](https://user-images.githubusercontent.com/17511668/224508753-a2de338a-ff2a-41e0-bbc1-ccc07a1d00ce.png)


# User-Facing Changes

New output/input format, better error handling for `from xml` and `to
xml` commands.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-12 12:35:42 +13:00
Bob Hyman
2e01bf9cba
add dirs command to std lib (#8368)
# Description

Prototype replacement for `enter`, `n`, `p`, `exit` built-ins
implemented as scripts in standard library.
MVP-level capabilities (rough hack), for feedback please. Not intended
to merge and ship as is.

_(Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.)_

# User-Facing Changes
New command in standard library

```nushell
〉use ~/src/rust/nushell/crates/nu-utils/standard_library/dirs.nu
---------------------------------------------- /home/bobhy ----------------------------------------------
〉help dirs
module dirs.nu -- maintain list of remembered directories + navigate them

todo:
* expand relative to absolute paths (or relative to some prefix?)
* what if user does `cd` by hand?

Module: dirs

Exported commands:
  add (dirs add), drop, next (dirs next), prev (dirs prev), show (dirs show)

This module exports environment.
---------------------------------------------- /home/bobhy ----------------------------------------------
〉dirs add ~/src/rust/nushell /etc ~/.cargo
-------------------------------------- /home/bobhy/src/rust/nushell --------------------------------------
〉dirs next 2
------------------------------------------- /home/bobhy/.cargo -------------------------------------------
〉dirs show
╭───┬─────────┬────────────────────╮
│ # │ current │        path        │
├───┼─────────┼────────────────────┤
│ 0 │         │ /home/bobhy        │
│ 1 │         │ ~/src/rust/nushell │
│ 2 │         │ /etc               │
│ 3 │ ==>     │ ~/.cargo           │
╰───┴─────────┴────────────────────╯
------------------------------------------- /home/bobhy/.cargo -------------------------------------------
〉dirs drop
---------------------------------------------- /home/bobhy ----------------------------------------------
〉dirs show
╭───┬─────────┬────────────────────╮
│ # │ current │        path        │
├───┼─────────┼────────────────────┤
│ 0 │ ==>     │ /home/bobhy        │
│ 1 │         │ ~/src/rust/nushell │
│ 2 │         │ /etc               │
╰───┴─────────┴────────────────────╯
---------------------------------------------- /home/bobhy ----------------------------------------------
〉
```
# Tests + Formatting

Haven't even looked at stdlib `tests.nu` yet.

Other todos:
* address module todos.
* integrate into std lib, rather than as standalone module. Somehow
arrange for `use .../standard_library/std.nu` to load this module
without having to put all the source in `std.nu`?
*  Maybe command should be `std dirs ...`?   
* what else do `enter` and `exit` do that this should do? Then deprecate
those commands.

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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-11 16:31:09 -06:00
JT
e435196956
Hack around bad binary viewing logic (#8399)
# Description

This works around a bug introduced by #8058 

We should revisit the original fix, as it makes some assumptions about
how stdout redirection is used by `table`. We use the stdout by default
for table regularly during a repl session, so we should instead
special-case case for handling externals.

# User-Facing Changes

Restores the original default `table` behaviour for binary data

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-11 14:13:37 +13:00
Jakub Žádník
af1ab39851
Allow aliasing parser keywords (#8250) 2023-03-10 23:20:31 +02:00
JT
baddc86d9d
Fix quicktest-found parser crash (#8394)
# Description

Fixes the crash when handing `{}#.}`

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-11 09:26:14 +13:00
Reilly Wood
de6bab59bf
Remove get -i from default env file (#8390)
This is a follow-up from https://github.com/nushell/nushell/pull/8173,
which was merged shortly after the 0.76 release. That PR changed
`default_env.nu` so that the user's home folder is displayed as `~` in
the left prompt. It did so using `get -i`.

This PR just rewrites the Nu code from
https://github.com/nushell/nushell/pull/8173 to use `try`/`catch`
instead of `-i`, which will make it easier to remove the `-i` flags from
`get` and `select` eventually (see
https://github.com/nushell/nushell/pull/8379).

I would like to merge this before the 0.77 release, so we don't end up
with lots of `env.nu` files using `get -i` out in the wild.
2023-03-10 19:39:11 +01:00
Klementiev Dmitry
0ff1cb1ea6
Reworking help aliases (#8372) 2023-03-10 20:14:55 +02:00
Reilly Wood
878e08cfa4
Fix the SQLite feature name in version (#8381)
A tiny fix: make the naming of the `sqlite` feature consistent across
both `Cargo.toml` and the `version` command's output. Previously
`version` displayed it as `database`, a user was asking about that the
other day.
2023-03-09 20:49:29 -08:00
Antoine Stevan
4e78f3649b
FEATURE: add the startup time to $nu (#8353)
# Description
in https://github.com/nushell/nushell/issues/8311 and the discord
server, the idea of moving the default banner from the `rust` source to
the `nushell` standar library has emerged 😋

however, in order to do this, one need to have access to all the
variables used in the default banner => all of them are accessible
because known constants, except for the startup time of the shell, which
is not anywhere in the shell...

#### this PR adds exactly this, i.e. the new `startup_time` to the `$nu`
variable, which is computed to have the exact same value as the value
shown in the banner.

## the changes
in order to achieve this, i had to
- add `startup_time` as an `i64` to the `EngineState` => this is, to the
best of my knowledge, the easiest way to pass such an information around
down to where the banner startup time is computed and where the `$nu`
variable is evaluated
- add `startup-time` to the `$nu` variable and use the `EngineState`
getter for `startup_time` to show it as a `Value::Duration`
- pass `engine_state` as a `&mut`able argument from `main.rs` down to
`repl.rs` to allow the setter to change the value of `startup_time` =>
without this, the value would not change and would show `-1ns` as the
default value...
- the value of the startup time is computed in `evaluate_repl` in
`repl.rs`, only once at the beginning, and the same value is used in the
default banner 👌

# User-Facing Changes
one can now access to the same time as shown in the default banner with
```bash
$nu.startup-time
```

# Tests + Formatting
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🟢 `cargo test --workspace`

# After Submitting
```
$nothing
```
2023-03-09 14:18:58 -06:00
David Matos
ccd72fa64a
Error out when config.nu has no editor configured (#8282)
# Description
Fixes #8245. Instead of trying to use `nano` or `notepad` as defaults,
it errors out if finds that `buffer_editor` , $EDITOR, $VISUAL do not
exist.

If the PR is landed, Ill update the website as it means what its in
there is no longer correct.
```
❯ config nu
Error: 
  × No editor configured
   ╭─[entry #3:1:1]
 1 │ config nu
   · ────┬────
   ·     ╰── Please specify one via environment variables $EDITOR or $VISUAL
   ╰────
  help: Nushell's config file can be found with the command: $nu.config-path. For more help: (https://nushell.sh/book/configuration.html#configurations-with-built-in-commands)
  
  ``` 
# User-Facing Changes

# Tests + Formatting


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

- [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 -A clippy::needless_collect` to check that you're using the standard code style
- [X] `cargo test --workspace` to check that all tests pass

# 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.
2023-03-09 08:07:20 -06:00
Reilly Wood
03e688ea7b
Revert to notify v4 (#8367)
This reverts https://github.com/nushell/nushell/pull/8114 which upgraded
to `notify` (a file watching crate used by the `watch` command) v5.

`notify` v5 has several breaking changes and it's much harder to use. It
no longer includes debouncing of file system events, which I think is
essential functionality for `watch`. @WindSoilder was going to try
writing our own debouncing functionality but I don't think he had time
to finish it.

@WindSoilder Is it OK if we revert this for the 0.77 release (March 14)?
We can try again for 0.78
2023-03-08 21:45:58 -08:00
StevenDoesStuffs
7e949595bd
Add is-interactive and is-login to NuVariable and allow running scripts with -i (#8306)
Add two rows in `$nu`, `$nu.is-interactive` and `$nu.is-login`, which
are true when nu is run in interactive and login mode respectively.

The `-i` flag now behaves a bit more like that of bash's, where the any
provided command or file is run without REPL but in "interactive mode".
This should entail sourcing interactive-mode config files, but since we
are planning on overhauling the config system soon, I'm holding off on
that. For now, all `-i` does is set `$nu.is-interactive` to be true.

About testing, I can't seem to find where cli-args get tested, so I
haven't written any new tests for this. Also I don't think there are any
docs that need updating. However if I'm wrong please tell me.
2023-03-08 20:59:33 -06:00
Artemiy
d31a51e3bc
Hide 7925 (#8359)
# Description

Hides https://github.com/nushell/nushell/pull/7925 from config and
disables by default. Option is still present in config, just hidden.

# User-Facing Changes

Users can no longer find `table.show_empty` in config and it is set to
false by default.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-09 10:26:59 +13:00
Darren Schroeder
0df847da15
fixed an error message that popped up after landing (#8356)
# Description

This PR fixes an error message that popped up after landing a PR #8337.
I guess there were too many changes since the PR was submitted?

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-07 19:02:48 -06:00
Antoine Stevan
6af59cb0ea
FEATURE: add a path add to the standard library (#8303)
# Description
this PR adds the `path add` command to
`crates/nu-utils/standard_library/std.nu`
- this comes from frequent questions over on the discord server, about
how to add directories to the `PATH`
- this is greatly inspired from the [original
`path-add`](https://discord.com/channels/601130461678272522/615253963645911060/1081206660816699402)
from @melMass
- allows to prepend and append a variable number of directories to the
`PATH`
- i've added a description with an example
- i've added tests in `crates/nu-utils/standard_library/tests.nu` that
hopefully covers all the features

# User-Facing Changes
`path add` can now be used from `std.nu`

# Tests + Formatting
the tests pass with
```bash
nu crates/nu-utils/standard_library/tests.nu
```

# After Submitting
```bash
$nothing
```
2023-03-07 17:06:14 -06:00
Bob Hyman
2ad0fcb377
Fix 8244 -- store timestamps with nanosecond resolution (consistently) (#8337)
# Description

Fix for data ambiguity noted in #8244.

Basic change is to use nanosecond resolution for unix timestamps (stored
in type Int). Previously, a timestamp might have seconds, milliseconds
or nanoseconds, but it turned out there were overlaps in data ranges
between different resolutions, so there wasn't always a unique mapping
back to date/time.

Due to higher precision, the *range* of dates that timestamps can map to
is restricted. Unix timestamps with seconds resolution and 64 bit
storage can cover all dates from the Big Bang to eternity. Timestamps
with seconds resolution and 32 bit storage can only represent dates from
1901-12-13 through 2038-01-19. The nanoseconds resolution and 64 bit
storage used with this fix can represent dates from 1677-09-21T00:12:44
to 2262-04-11T23:47:16, something of a compromise.

# User-Facing Changes
_(List of all changes that impact the user experience here. This helps
us keep track of breaking changes.)_

## `<datetime> | into int`
Converts to nanosecond resolution
```rust
〉date now | into int
1678084730502126846
```
This is the number of non-leap nanoseconds after the unix epoch date:
1970-01-01T00:00:00+00:00.

Conversion fails for dates outside the supported range:
```rust
〉1492-10-12 | into int
Error: nu:🐚:incorrect_value

  × Incorrect value.
   ╭─[entry #51:1:1]
 1 │ 1492-10-12 | into int
   ·              ────┬───
   ·                  ╰── DateTime out of timestamp range 1677-09-21T00:12:43 and 2262-04-11T23:47:16
   ╰────


```

## `<int> | into datetime`
Can no longer fail or produce incorrect results for any 64-bit input:
```rust
〉0 | into datetime 
Thu, 01 Jan 1970 00:00:00 +0000 (53 years ago)
〉"7fffffffffffffff" | into int -r 16 | into datetime
Fri, 11 Apr 2262 23:47:16 +0000 (in 239 years)
〉("7fffffffffffffff" | into int -r 16) * -1 | into datetime
Tue, 21 Sep 1677 00:12:43 +0000 (345 years ago)
```

## `<date> | date to-record` and `<date> | date to-table`
Now both have a `nanosecond` field.  
```rust
〉"7fffffffffffffff" | into int -r 16 | into datetime | date to-record
╭────────────┬───────────╮
│ year       │ 2262      │
│ month      │ 4         │
│ day        │ 11        │
│ hour       │ 23        │
│ minute     │ 47        │
│ second     │ 16        │
│ nanosecond │ 854775807 │
│ timezone   │ +00:00    │
╰────────────┴───────────╯
〉"7fffffffffffffff" | into int -r 16 | into datetime | date to-table
╭───┬──────┬───────┬─────┬──────┬────────┬────────┬────────────┬──────────╮
│ # │ year │ month │ day │ hour │ minute │ second │ nanosecond │ timezone │
├───┼──────┼───────┼─────┼──────┼────────┼────────┼────────────┼──────────┤
│ 0 │ 2262 │     4 │  11 │   23 │     47 │     16 │  854775807 │ +00:00   │
╰───┴──────┴───────┴─────┴──────┴────────┴────────┴────────────┴──────────╯
```

This change was not mandated by the OP problem, but it is nice to be
able to see the nanosecond bits that were present in Nushell `date` type
all along.
# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-07 17:02:15 -06:00
Antoine Stevan
f34034ae58
FIX: redirect to encode base64 as hash bash64 is deprecated (#8351)
# Description
i tried yesterday to `encode` with an invalid character set and this is
what i got
```bash
>_ {alg: "HS256", type: "JWT"} | to json -r | encode base64 --character-set invalid-character-set
Error:
  × value is not an accepted character set
   ╭─[entry #11:1:1]
 1 │ {alg: "HS256", type: "JWT"} | to json -r | encode base64 --character-set invalid-character-set
   ·                                                                          ──────────┬──────────
   ·                                                                                    ╰── invalid-character-set is not a valid character-set.
Please use `help hash base64` to see a list of valid character sets.
   ╰────
```

but `hash base64` is now a deprecated command, see `help hash base64`.

=> **this PR changes the error message to mention `help encode base64`,
where the list of valid character sets is, instead**

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🟢 `cargo test --workspace`

# After Submitting
```
$nothing
```
2023-03-07 20:04:54 +01:00
Reilly Wood
0e2167884d
Add SSL tests for http get (#8327)
This PR adds tests to confirm that:
1. `http get` does the right thing (bail) when it encounters common SSL
errors
2. the `--insecure` flag works to ignore SSL errors

It's prompted by #8098, where `--insecure` stopped working and we didn't
notice until it was reported by a user.

## Deets + considerations

This PR uses [badssl.com](https://badssl.com/), a very handy website
affiliated with the Google Chrome team. The badssl authors mention that
stability is not guaranteed:

> Most subdomains are likely to have stable functionality, but anything
could change without notice.

I suspect that the badssl.com subdomains I've chosen will be stable
enough in practice. Can revisit this if the tests end up being flaky.

This PR does mean our tests are now making an external network call...
which I _think_ is OK. Our CI isn't exactly designed for offline
machines; test runners already have to download a bunch of crates etc. I
think the new tests are quick enough:


![image](https://user-images.githubusercontent.com/26268125/222992751-a9f0d8ff-b776-4ea5-908a-7d11607487fe.png)
2023-03-07 07:56:39 -08:00
Reilly Wood
e445c41454
Fix to json for SQLite databases (#8343)
Fixes #8341. 

The `CustomValue::to_json()` function is an odd duck; it defaults to
returning `null`, and no `CustomValue` implementations override it to do
anything useful. I forgot to implement `to_json()` for `SQLiteDatabase`,
so `open foo.db | to json` was returning `null`.

To fix this, I've removed `CustomValue::to_json()` and now `to json`
will collect a `CustomValue` into a regular `Value` before doing a JSON
conversion.
2023-03-06 14:36:26 -08:00
Stefan Holderbach
62575c9a4f
Document and critically review ShellError variants - Ep. 3 (#8340)
Continuation of #8229 and #8326

# Description

The `ShellError` enum at the moment is kind of messy. 

Many variants are basic tuple structs where you always have to reference
the implementation with its macro invocation to know which field serves
which purpose.
Furthermore we have both variants that are kind of redundant or either
overly broad to be useful for the user to match on or overly specific
with few uses.

So I set out to start fixing the lacking documentation and naming to
make it feasible to critically review the individual usages and fix
those.
Furthermore we can decide to join or split up variants that don't seem
to be fit for purpose.

# Call to action

**Everyone:** Feel free to add review comments if you spot inconsistent
use of `ShellError` variants.

# User-Facing Changes

(None now, end goal more explicit and consistent error messages)

# Tests + Formatting

(No additional tests needed so far)

# Commits (so far)

- Remove `ShellError::FeatureNotEnabled`
- Name fields on `SE::ExternalNotSupported`
- Name field on `SE::InvalidProbability`
- Name fields on `SE::NushellFailed` variants
- Remove unused `SE::NushellFailedSpannedHelp`
- Name field on `SE::VariableNotFoundAtRuntime`
- Name fields on `SE::EnvVarNotFoundAtRuntime`
- Name fields on `SE::ModuleNotFoundAtRuntime`
- Remove usused `ModuleOrOverlayNotFoundAtRuntime`
- Name fields on `SE::OverlayNotFoundAtRuntime`
- Name field on `SE::NotFound`
2023-03-06 18:33:09 +01:00
Reilly Wood
4898750fc1
Remove body parameters from http get (#8336)
`http get` has 2 parameters which are used for setting the body of the
HTTP request. They don't make sense because [GET requests should have no
body](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET):


![image](https://user-images.githubusercontent.com/26268125/223032130-764d0313-df00-48a6-80a5-0d8ff296b8ae.png)
2023-03-06 08:49:28 -08:00
Stefan Holderbach
f7b8f97873
Document and critically review ShellError variants - Ep. 2 (#8326)
Continuation of #8229 

# Description

The `ShellError` enum at the moment is kind of messy. 

Many variants are basic tuple structs where you always have to reference
the implementation with its macro invocation to know which field serves
which purpose.
Furthermore we have both variants that are kind of redundant or either
overly broad to be useful for the user to match on or overly specific
with few uses.

So I set out to start fixing the lacking documentation and naming to
make it feasible to critically review the individual usages and fix
those.
Furthermore we can decide to join or split up variants that don't seem
to be fit for purpose.

**Everyone:** Feel free to add review comments if you spot inconsistent
use of `ShellError` variants.

- Name fields of `SE::IncorrectValue`
- Merge and name fields on `SE::TypeMismatch`
- Name fields on `SE::UnsupportedOperator`
- Name fields on `AssignmentRequires*` and fix doc
- Name fields on `SE::UnknownOperator`
- Name fields on `SE::MissingParameter`
- Name fields on `SE::DelimiterError`
- Name fields on `SE::IncompatibleParametersSingle`

# User-Facing Changes

(None now, end goal more explicit and consistent error messages)

# Tests + Formatting

(No additional tests needed so far)
2023-03-06 11:31:07 +01:00
dependabot[bot]
4ae1b1cc26
Bump scraper from 0.14.0 to 0.15.0 (#8331)
Bumps [scraper](https://github.com/causal-agent/scraper) from 0.14.0 to
0.15.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/causal-agent/scraper/releases">scraper's
releases</a>.</em></p>
<blockquote>
<h2>0.15.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Bump cssparser to 0.28 and selectors to 0.23. by <a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a>
in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/99">causal-agent/scraper#99</a></li>
<li>Create dependabot.yml by <a
href="https://github.com/mohe2015"><code>@​mohe2015</code></a> in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/97">causal-agent/scraper#97</a></li>
<li>Re-export Element trait from selectors crate by <a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a>
in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/98">causal-agent/scraper#98</a></li>
<li>build(deps): fix unchecked lock and update deps by <a
href="https://github.com/j-mendez"><code>@​j-mendez</code></a> in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/107">causal-agent/scraper#107</a></li>
<li>Re-export selectors' CaseSensitivity enum as it is part of our
public API. by <a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a>
in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/108">causal-agent/scraper#108</a></li>
<li>perf(element): add one sweep element creation by <a
href="https://github.com/j-mendez"><code>@​j-mendez</code></a> in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/109">causal-agent/scraper#109</a></li>
<li>Added feature flag <code>atomic</code> to make use of atomic
<code>StrTendril</code> type. by <a
href="https://github.com/jaboatman"><code>@​jaboatman</code></a> in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/102">causal-agent/scraper#102</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/99">causal-agent/scraper#99</a></li>
<li><a href="https://github.com/mohe2015"><code>@​mohe2015</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/97">causal-agent/scraper#97</a></li>
<li><a href="https://github.com/j-mendez"><code>@​j-mendez</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/107">causal-agent/scraper#107</a></li>
<li><a href="https://github.com/jaboatman"><code>@​jaboatman</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/pull/102">causal-agent/scraper#102</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/causal-agent/scraper/compare/v0.14.0...v0.15.0">https://github.com/causal-agent/scraper/compare/v0.14.0...v0.15.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="3cb7e9a320"><code>3cb7e9a</code></a>
Version 0.15.0</li>
<li><a
href="06f395efe0"><code>06f395e</code></a>
Apply clippy suggestion</li>
<li><a
href="ec91bf1ebc"><code>ec91bf1</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/issues/102">#102</a>
from jaboatman/master</li>
<li><a
href="4b7fb13446"><code>4b7fb13</code></a>
Merge remote-tracking branch 'upstream/master'</li>
<li><a
href="aa479ea170"><code>aa479ea</code></a>
perf(element): add one sweep element creation (<a
href="https://github-redirect.dependabot.com/causal-agent/scraper/issues/109">#109</a>)</li>
<li><a
href="9a6a638db2"><code>9a6a638</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/issues/108">#108</a>
from adamreichold/also-re-export-case-sensitivity</li>
<li><a
href="794b5eef87"><code>794b5ee</code></a>
Re-export selectors' CaseSensitivity enum as it is part of our public
API.</li>
<li><a
href="6abb8cd625"><code>6abb8cd</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/causal-agent/scraper/issues/107">#107</a>
from j-mendez/master</li>
<li><a
href="c3dd2600dc"><code>c3dd260</code></a>
chore(minor): fix element classes map format</li>
<li><a
href="b7955b9049"><code>b7955b9</code></a>
perf(selectors): add lazy classes map</li>
<li>Additional commits viewable in <a
href="https://github.com/causal-agent/scraper/compare/v0.14.0...v0.15.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=scraper&package-manager=cargo&previous-version=0.14.0&new-version=0.15.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 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>
2023-03-05 19:37:22 -08:00
dependabot[bot]
b7a34498e3
Bump rust-embed from 6.4.1 to 6.6.0 (#8330)
Bumps [rust-embed](https://github.com/pyros2097/rust-embed) from 6.4.1
to 6.6.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pyrossh/rust-embed/blob/master/changelog.md">rust-embed's
changelog</a>.</em></p>
<blockquote>
<h2>[6.6.0] - 2023-03-05</h2>
<ul>
<li>sort_by_file_name() requires walkdir v2.3.2 <a
href="https://github-redirect.dependabot.com/pyrossh/rust-embed/issues/206">#206</a></li>
<li>Add <code>mime-guess</code> feature to statically store mimetype <a
href="https://github-redirect.dependabot.com/pyrossh/rust-embed/issues/192">#192</a></li>
</ul>
<h2>[6.4.2] - 2022-10-20</h2>
<ul>
<li>Fail the proc macro if include/exclude are used without the feature
<a
href="https://github-redirect.dependabot.com/pyrossh/rust-embed/issues/187">#187</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/pyros2097/rust-embed/commits">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rust-embed&package-manager=cargo&previous-version=6.4.1&new-version=6.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 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>
2023-03-05 19:36:14 -08:00
dependabot[bot]
10fd3115c2
Bump rayon from 1.6.1 to 1.7.0 (#8328)
Bumps [rayon](https://github.com/rayon-rs/rayon) from 1.6.1 to 1.7.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/rayon-rs/rayon/blob/master/RELEASES.md">rayon's
changelog</a>.</em></p>
<blockquote>
<h1>Release rayon 1.7.0 / rayon-core 1.11.0 (2023-03-03)</h1>
<ul>
<li>The minimum supported <code>rustc</code> is now 1.59.</li>
<li>Added a fallback when threading is unsupported.</li>
<li>The new <code>ParallelIterator::take_any</code> and
<code>skip_any</code> methods work like
unordered <code>IndexedParallelIterator::take</code> and
<code>skip</code>, counting items in
whatever order they are visited in parallel.</li>
<li>The new <code>ParallelIterator::take_any_while</code> and
<code>skip_any_while</code> methods work
like unordered <code>Iterator::take_while</code> and
<code>skip_while</code>, which previously had
no parallel equivalent. The &quot;while&quot; condition may be satisfied
from anywhere
in the parallel iterator, affecting all future items regardless of
position.</li>
<li>The new <code>yield_now</code> and <code>yield_local</code>
functions will cooperatively yield
execution to Rayon, either trying to execute pending work from the
entire
pool or from just the local deques of the current thread,
respectively.</li>
</ul>
<h1>Release rayon-core 1.10.2 (2023-01-22)</h1>
<ul>
<li>Fixed miri-reported UB for SharedReadOnly tags protected by a
call.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="7ffaf3463b"><code>7ffaf34</code></a>
Merge <a
href="https://github-redirect.dependabot.com/rayon-rs/rayon/issues/716">#716</a></li>
<li><a
href="163003e0e3"><code>163003e</code></a>
bump the release date</li>
<li><a
href="f7d75532fc"><code>f7d7553</code></a>
Release rayon 1.3.0 / rayon-core 1.7.0</li>
<li><a
href="b98bb23f05"><code>b98bb23</code></a>
Remove unneeded extern crate statements</li>
<li><a
href="9b92c7deb9"><code>9b92c7d</code></a>
cargo fmt</li>
<li><a
href="e02f439bbf"><code>e02f439</code></a>
Remove useless 'use crate;' in favor of the crate prelude</li>
<li><a
href="a1db0fe390"><code>a1db0fe</code></a>
Fix clippy::flat_map_identity</li>
<li><a
href="4e4025693f"><code>4e40256</code></a>
Update ci/compat-Cargo.lock</li>
<li><a
href="1f9d117d51"><code>1f9d117</code></a>
Remove cfg(rayon_unstable)</li>
<li><a
href="198ca7f6aa"><code>198ca7f</code></a>
Remove rayon-futures</li>
<li>Additional commits viewable in <a
href="https://github.com/rayon-rs/rayon/compare/rayon-core-v1.6.1...rayon-core-v1.7.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rayon&package-manager=cargo&previous-version=1.6.1&new-version=1.7.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 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>
2023-03-05 19:32:16 -08:00
Reilly Wood
a4952bc029
Put a lock around cargo build invocations for plugin tests (#8333)
I think this _might_ fix the issues we've been seeing with plugin tests.

In a nutshell, the plugin tests run `cargo build` to ensure that plugins
have been built:
f6ca62384e/crates/nu-test-support/src/commands.rs (L6)

This PR adds a mutex to ensure that we're never running `cargo build`
concurrently. It also uses an atomic bool to signal when plugins have
already been built, so we can avoid invoking `cargo build` multiple
times unnecessarily.

I can't be certain yet, but I'm guessing the macOS CI problems we've
been seeing come from plugin tests clobbering each other (something
like: test 1 builds the `foo` plugin, then test2 invokes `cargo build`
again and deletes the `foo` plugin from disk).
2023-03-05 19:04:12 -08:00
Filip Andersson
f6ca62384e
changes Reqwest to Ureq. (#8320)
# Description

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

This pull request removes `Reqwest` and replaces it with `Ureq` to
remove some of our dependencies, giving us faster compile times as well
as smaller binaries. `Ureq` does not have an async runtime included so
we do not need build heavy dependencies such as `Tokio`. From older
tests I had the number of build units be reduced from `430 -> 392`.
The default of `Ureq` uses `Rustls` but it has been configured to
instead use `native_tls` which should work exactly the same as the `tls`
works now.
I removed `content-length` from the http commands as after refactoring i
did not see a reason to have it available, correct me if this is
something we should preserve.

In the medium, to long term, we should maybe consider changing to
`rustls` to have the same `tls` on all platforms.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-05 14:48:13 -08:00
Antoine Stevan
d6141881f2
FEATURE: add the example results to the scope (#8319)
Related to #8189.
Should close #8302.

Important to:
- have a complete `$nu` structure with all available information
- generate an accurate website, because the `make_docs.nu` script of
`nushell.github.io` uses `$nu.scope.command` to generate the pages of
https://nushell.sh/commands/

> **Note**
> i was looking for "scope" in the source of `nushell` to augment
`$nu.scope` and i found `crates/nu-engine/src/scope.rs` that defines
`nu_engine::scope::create_scope` which lead me to
`nu_engine::scope::ScopeData.collect_commands`.
> i hope this is the right file 😌 

# Description
this PR slightly modifies
`nu_engine::scope::ScopeData.collect_commands`:
- add the "result" column to `$nu.scope.commands.examples`
- put the result of the example when a valid `Option(Value)`
- put a `Value::Nothing` when the result is set to `None` in the source
of the command

# User-Facing Changes
users can now access the results of all examples in
```bash
$nu.scope.commands | where name == <command> | get examples.0.result
```

## example...
### ...with a command that defines examples: `merge`
```bash
>_ $nu.scope.commands | where name == merge | get examples.0 | reject description | table --expand
╭───┬────────────────────────────────────────────────────────┬───────────────────────────╮
│ # │                        example                         │          result           │
├───┼────────────────────────────────────────────────────────┼───────────────────────────┤
│ 0 │ [a b c] | wrap name | merge ( [1 2 3] | wrap index )   │ ╭───┬──────╮              │
│   │                                                        │ │ # │ name │              │
│   │                                                        │ ├───┼──────┤              │
│   │                                                        │ │ 1 │ a    │              │
│   │                                                        │ │ 2 │ b    │              │
│   │                                                        │ │ 3 │ c    │              │
│   │                                                        │ ╰───┴──────╯              │
│ 1 │ {a: 1, b: 2} | merge {c: 3}                            │ ╭───┬───╮                 │
│   │                                                        │ │ a │ 1 │                 │
│   │                                                        │ │ b │ 2 │                 │
│   │                                                        │ │ c │ 3 │                 │
│   │                                                        │ ╰───┴───╯                 │
│ 2 │ [{columnA: A0 columnB: B0}] | merge [{columnA: 'A0*'}] │ ╭───┬─────────┬─────────╮ │
│   │                                                        │ │ # │ columnA │ columnB │ │
│   │                                                        │ ├───┼─────────┼─────────┤ │
│   │                                                        │ │ 0 │ A0*     │ B0      │ │
│   │                                                        │ ╰───┴─────────┴─────────╯ │
╰───┴────────────────────────────────────────────────────────┴───────────────────────────╯
```
and we can check that these are "true" results and not just string, e.g.
```bash
>_ $nu.scope.commands | where name == merge | get examples.0.result.0 | describe
table<name: string, index: int>
```
### ...with a command without any example: `open`
```bash
>_ $nu.scope.commands | where name == open | get examples.0 | reject description | table --expand
╭───┬──────────────────────────────────────┬────────╮
│ # │               example                │ result │
├───┼──────────────────────────────────────┼────────┤
│ 0 │ open myfile.json                     │        │
│ 1 │ open myfile.json --raw               │        │
│ 2 │ 'myfile.txt' | open                  │        │
│ 3 │ open myfile.txt --raw | decode utf-8 │        │
╰───┴──────────────────────────────────────┴────────╯
```
and same thing, we can check that there is `$nothing` in this last
command
```bash
>_ $nu.scope.commands | where name == open | get examples.0.result.0 | describe
table<name: string, index: int>
```

# Tests + Formatting
- ✔️ `cargo fmt --all`
- ✔️ `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- ✔️ `cargo test --workspace` (~~currently running~~)

# After Submitting
the documentation would have to be regenerated!
2023-03-05 10:56:06 +01:00
Reilly Wood
f93033c20b
Fix CPU usage info in sys (#8321)
Closes #8264. This PR does a few things to fix the `usage` column in
`sys.cpu`:

1. Sleep a while (~400ms) between calls to `sys.refresh_cpu()`, [as
required by
`sysinfo`](https://docs.rs/sysinfo/latest/sysinfo/trait.SystemExt.html#method.refresh_cpu)
2. Change `sys` to return a `LazyRecord` (so you can do things like `sys
| get host` instantly without waiting for CPU info)
3. Update our `sysinfo` dependency to [fix CPU usage calculations on
Linux](https://github.com/GuillaumeGomez/sysinfo/pull/946)

CPU usage is no longer always reported as zero:


![image](https://user-images.githubusercontent.com/26268125/222929775-5e9cbe18-95d9-4ecb-baf8-1e843f5c7086.png)
2023-03-04 14:48:34 -08:00
Jérémy Audiger
33fb17776a
Update the command 'version'. (#8312)
# Description

No real changes, just some cleanup while I was looking at the code of
the command.

# User-Facing Changes

Remove the attribute 'pkg_version', since it's already exposed through
'version'.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-04 16:23:30 -06:00
Antoine Stevan
b864a455f2
DOC: add a README to the standard library (#8304)
# Description
this PR a `README` to the standard library in
`crates/nu-utils/standard_library/` 👍

> **Note**
> you can have a look at what the `README` looks like
[here](https://github.com/amtoine/nushell/blob/doc/add-a-readme-to-the-standard-library/crates/nu-utils/standard_library/README.md#--welcome-to-the-standard-library-of-nushell--)

# User-Facing Changes
the user can now access some documentation about the standard library. 

# Tests + Formatting
```
$nothing
```

# After Submitting
```
$nothing
```
2023-03-04 08:30:36 -06:00
Jérémy Audiger
b9c78a05aa
Resolve Clippy warnings inside tests. (#8315)
# Description

Command: `cargo clippy --workspace --all-targets`

Resolve those warnings:

```
warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> crates/nu-parser/tests/test_parser.rs:86:59
   |
86 |             compare_rhs_binaryOp(test_tag, &expected_val, &observed_val);
   |                                                           ^^^^^^^^^^^^^ help: change this to: `observed_val`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default

warning: `assert!(false, ..)` should probably be replaced
   --> crates/nu-cli/src/completions/command_completions.rs:319:17
    |
319 |                 assert!(false, "Merge delta has failed: {}", err);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!(..)` or `unreachable!(..)`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
    = note: `#[warn(clippy::assertions_on_constants)]` on by default

warning: 1 warning emitted

warning: `assert!(false, ..)` should probably be replaced
   --> crates/nu-cli/src/completions/completer.rs:600:13
    |
600 |             assert!(false, "Error merging delta: {:?}", err);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!(..)` or `unreachable!(..)`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants

warning: length comparison to zero
   --> crates/nu-cli/src/completions/completer.rs:620:24
    |
620 |             assert_eq!(result.len() > 0, has_result, "line: {}", line);
    |                        ^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!result.is_empty()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
    = note: `#[warn(clippy::len_zero)]` on by default

warning: equality checks against true are unnecessary
   --> crates/nu-cli/src/completions/completer.rs:632:33
    |
632 |                     .filter(|x| *x == true)
    |                                 ^^^^^^^^^^ help: try simplifying it as shown: `*x`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
    = note: `#[warn(clippy::bool_comparison)]` on by default

    Checking nu v0.76.1 (/home/jaudiger/Development/git-repositories/jaudiger/nushell)
warning: 4 warnings emitted

warning: the borrowed expression implements the required traits
  --> crates/nu-command/tests/commands/cp.rs:26:40
   |
26 |         let first_hash = get_file_hash(&test_file.display());
   |                                        ^^^^^^^^^^^^^^^^^^^^ help: change this to: `test_file.display()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default

warning: the borrowed expression implements the required traits
   --> crates/nu-command/tests/commands/cp.rs:178:13
    |
178 |             &jonathans_expected_copied_dir
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `jonathans_expected_copied_dir`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: the borrowed expression implements the required traits
   --> crates/nu-command/tests/commands/cp.rs:182:13
    |
182 |             &andres_expected_copied_dir
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `andres_expected_copied_dir`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: the borrowed expression implements the required traits
   --> crates/nu-command/tests/commands/cp.rs:186:13
    |
186 |             &yehudas_expected_copied_dir
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `yehudas_expected_copied_dir`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: 4 warnings emitted
```

# User-Facing Changes

None.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-04 14:58:20 +01:00
ygguser
26c36e932e
README for nu-json. Related to nushell/nushell#8253 (#8289)
I propose to add such a README file for the nu-json crate.
The crate is good, it is used also by others. However, on crates.io [its
page](https://crates.io/crates/nu-json) looks uninformative.

Related to https://github.com/nushell/nushell/issues/8253

---------

Co-authored-by: ygguser <there_is@no.email>
2023-03-03 19:07:25 -06:00
johnny-byte
bd096430cb
remove extra allocation from nu-json (#8299)
# Description

Remove unnecessary memory allocation

# User-Facing Changes

None

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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: None <>
2023-03-03 17:01:56 -08:00
JT
6148314dcd
print pipeline contents in print (#8305)
# Description

Have `print` print it's input, so it's easier to print a pipeline (esp
after we land #8292 and related)

# User-Facing Changes

`print` will now print its input, if there are no args given

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-04 11:31:01 +13:00
Jérémy Audiger
a7b5bd18ba
Shadow rs dep (#8298)
# Description

While looking at the recent MR merged, I noticed that a dependency was
no more used with https://github.com/nushell/nushell/pull/8280.

# User-Facing Changes

None.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-03 09:41:13 -08:00
mike
e01eb42e74
fix NotAConstant error help message (#8293)
```
Error: nu::parser::not_a_constant (link)

  × Not a constant.
   ╭─[entry #23:1:1]
 1 │ let file = "/home/user/file"; source $file
   ·                                      ──┬──
   ·                                        ╰── Value is not a parse-time constant
   ╰────
  help: Only a subset of expressions are allowed
        constants during parsing. Try using the 'let'
        command or typing the value literally.
```
this pr changes the help message to 'Try using the `const` command ...'
2023-03-02 19:07:25 -06:00
Jérémy Audiger
c1d76bfac7
Add unit tests for HTTP commands. (#8267)
# Description

Following the comment from @fdncred:
https://github.com/nushell/nushell/pull/8144#issuecomment-1442514338. I
added some unit tests for HTTP commands. The tests are not exhaustive,
but at least, this is a first good step IMO.

# User-Facing Changes

None.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-02 11:05:18 -08:00
Doru
1a62d87a42
Make the default prompt play nice with basic fonts (#8080)
# Description
This commit changes the `PROMPT_INDICATOR` and
`PROMPT_INDICATOR_VI_NORMAL` in the default_env and sample_login files.
It also changes its missing fallback in the prompt.rs file.

This has the intention of making the default prompt friendlier when
dealing with basic terminals that may not support displaying a huge
range of the Unicode standard, or users who don't want to get out of
their way to install custom fonts for their terminals. It's also
nicer/more balanced on the eyes, to me, and brings it in line with the
logo of nushell `nu>`.

# User-Facing Changes
New installations of nushell will have > as the default prompt
indicator, and running `config reset` will also change it. This might be
confusing for a few seconds, it could be minor enough that it just feels
slightly off. Anyone who has, for some reason, unset the
PROMPT_INDICATOR variable, or set it to $nothing, will also receive the
`>` treatment.

Users running on basic terminals (like cmd.exe on Windows 10) should no
longer face font issues with the default basic prompt.

# Drawbacks
The Unicode arrow is pretty cool. And it predates many of us. Maybe it's
worth keeping. One argument I could see, and mildly disagree with, is
that it might make users lean towards installing a modern font for their
terminal which will would have good consequences in the future.
2023-03-02 13:59:32 +13:00
Antoine Stevan
2ccbefe01e
REFACTOR: move the standard library to a less-confusing place (#8265)
# Description
we've discussed a bit about the location of the standard library in the
#standard-library channel of the discord server => **the previous
location, `crates/nu-utils/src/sample_config/`, was a bit confusing**
- is `std.nu` a config file, just as `default_config.nu` or
`default_env.nu`?
- what is this `tests.nu` file inside the `sample_config/`?

in this PR, i propose moving the standard library to
`crates/nu-utils/standard_library/` for a few reasons:
- `std.nu` is not a config file, so it should not be next to config
files in a `sample_config/` directory
- `tests.nu` is confusing if mixed with other unrelated files
- `crates/nu-utils/` appears to be a good place for the standard library
as it is meant to be a tool for `nushell`
- i thought it would be strange to have `std.nu` inside
`crates/nu-utils/src/` as this directory is generally filled with `rust`
files, right?

these are the reasons why i choose to propose
`crates/nu-utils/standard_library/` 😋

# User-Facing Changes
the standard library is now used with
```bash
use crates/nu-utils/standard_library/std.nu
```
and the tests are run with
```bash
nu crates/nu-utils/standard_library/tests.nu
```

# Tests + Formatting
```bash
$nothing
```

# After Submitting
```bash
$nothing
```
2023-03-01 16:40:50 -06:00
Stefan Holderbach
438062d7fc
Document and critically review ShellError variants - Ep. 1 (#8229)
# Description

The `ShellError` enum at the moment is kind of messy. 

Many variants are basic tuple structs where you always have to reference
the implementation with its macro invocation to know which field serves
which purpose.
Furthermore we have both variants that are kind of redundant or either
overly broad to be useful for the user to match on or overly specific
with few uses.

So I set out to start fixing the lacking documentation and naming to
make it feasible to critically review the individual usages and fix
those.
Furthermore we can decide to join or split up variants that don't seem
to be fit for purpose.

Feel free to add review comments if you spot inconsistent use of
`ShellError` variants.

- Name fields on `ShellError::OperatorOverflow`
- Name fields on `ShellError::PipelineMismatch`
- Add doc to `ShellError::OnlySupportsThisInputType`
- Name `ShellError::OnlySupportsThisInputType`
- Name field on `ShellError::PipelineEmpty`
- Comment about issues with `TypeMismatch*`
- Fix a few `exp_input_type`s
- Name fields on `ShellError::InvalidRange`

# User-Facing Changes

(None now, end goal more explicit and consistent error messages)

# Tests + Formatting

(No additional tests needed so far)
2023-03-01 20:34:48 +01:00
Michael Angerman
5bf077d64f
remove left over build.rs from nu-command (#8280)
@fdncred pointed out to me that post creation of the nu-cmd-lang crate
we probably don't need an extra build.rs
file in nu-command any longer now that the version command (and
build.rs) is located in nu-cmd-lang...

I am removing the redundancy...
2023-03-01 09:30:58 -08:00
WindSoilder
dec0a2517f
Throw out error if external command in subexpression is failed to run (#8204) 2023-03-01 13:50:38 +02:00
Reilly Wood
324d625324
Fix CPU frequency in sys output (#8275)
The `sys | get cpu.freq` column (supposed to contain the frequency for
each CPU core in megahertz) was incorrect for 2 reasons:
1. We weren't telling the `sysinfo` crate to refresh CPU frequency info
2. We were overwriting the values in the column with the systemwide
physical core count. Whoops!

### Before


![image](https://user-images.githubusercontent.com/26268125/222045977-2c021c92-794f-4498-b12c-e3a1bbaa7483.png)

### After


![image](https://user-images.githubusercontent.com/26268125/222046066-ff8ccd21-3c47-4d7d-8f14-e0744822cd2d.png)


## Future work

This PR does not fix https://github.com/nushell/nushell/issues/8264 ;
the `cpu_usage` column is still incorrect.
2023-03-01 21:31:05 +13:00
JT
e22b70acff
Remove the 'env' command, as we have the variable (#8185)
# Description

Removes the `env` command, as the `$env` is generally a much better
experience.

# User-Facing Changes

Breaking change: Removes `env`.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-03-01 21:20:00 +13:00
Jérémy Audiger
a5c604c283
Uniformize usage() and extra_usage() message ending for commands helper. (#8268)
# Description

Working on uniformizing the ending messages regarding methods usage()
and extra_usage(). This is related to the issue
https://github.com/nushell/nushell/issues/5066 after discussing it with
@jntrnr

# User-Facing Changes

None.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-28 21:33:02 -08:00
Ryan Devenney
644164fab3
math floor and ceil round to int rather than float #8258 (#8269)
# Description

#8258 

Math floor and ceil return int types rather than floats.

# User-Facing Changes

Before:
```
/home/rdevenney/projects/open_source/nushell〉[(3.14 | math ceil | describe), 
(3.14 | math floor | describe), 
(3 | math ceil | describe), 
(3 | math floor | describe)]
╭───┬───────╮
│ 0 │ float │
│ 1 │ float │
│ 2 │ int   │
│ 3 │ int   │
╰───┴───────╯

```

After:
```
/home/rdevenney/projects/open_source/nushell〉[(3.14 | math ceil | describe), 
(3.14 | math floor | describe), 
(3 | math ceil | describe), 
(3 | math floor | describe)]
╭───┬─────╮
│ 0 │ int │
│ 1 │ int │
│ 2 │ int │
│ 3 │ int │
╰───┴─────╯

```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-28 21:28:16 -08:00
Victor Wong
592e677caf
Type mismatch span fix #7288 (#8271)
# Description

This change fixes the bug associated with an incorrect span in
`type_mismatch` error message as described in #7288

The `span` argument in the method `into_value` was not being used to
convert a `PipelineData::Value` type so when called in
[eval_expression](https://github.com/nushell/nushell/blob/main/crates/nu-engine/src/eval.rs#L514-L515),
the original expression's span was not being used to overwrite the
result of `eval_subexpression`.

# User-Facing Changes

Using the example described in the issue, the whole bracketed
subexpression is correctly underlined.

Behavior before change:

```
let val = 10
($val | into string) + $val
Error: nu:🐚:type_mismatch

  × Type mismatch during operation.
   ╭─[entry #2:1:1]
 1 │ ($val | into string) + $val
   ·         ─────┬─────  ┬ ──┬─
   ·              │       │   ╰── int
   ·              │       ╰── type mismatch for operator
   ·              ╰── string
   ╰────
```

Behavior after change:
```
let val = 10
($val | into string) + $val
Error: nu:🐚:type_mismatch

  × Type mismatch during operation.
   ╭─[entry #2:1:1]
 1 │ ($val | into string) + $val
   · ──────────┬───────── ┬ ──┬─
   ·           │          │   ╰── int
   ·           │          ╰── type mismatch for operator
   ·           ╰── string
   ╰────
```


# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-28 21:12:53 -08:00
Reilly Wood
cc7bdebc1c
Switch http to https in banner (#8272)
Changing `http` to `https` in the banner now that `https://nushell.sh`
works: https://github.com/nushell/nushell.github.io/issues/294
2023-02-28 20:32:31 -08:00
Jérémy Audiger
50f1e33965
Fix insecure + max-time arguments for HTTP commands. (#8266)
# Description

Follow up of https://github.com/nushell/nushell/pull/8255

Sorry about the max-time argument, I didn't pay attention to the
copy-paste. Regarding the insecure argument, the problem was before I
began to work on the refacto. My mistake was to not have tested this
argument.

# User-Facing Changes

None.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-28 14:33:28 -06:00
alesito85
ffc3727a1e
Fixes insecure and timeout flags (#8255)
# Description

Fixes #8098 by properly parsing `insecure` flag and also fixes the
`timeout` flag, which is described as `max-time` (from curl?).

# User-Facing Changes

The only change is that the flags now work.

# Tests + Formatting

Everything passes.

# Screenshots

Before

![image](https://user-images.githubusercontent.com/4399118/221845043-6dfba69d-daea-49a7-b55c-7ee628551b1c.png)

After


![image](https://user-images.githubusercontent.com/4399118/221845382-0111cbe9-4ba6-4de1-9e2a-655efbc65a26.png)
2023-02-28 06:48:15 -06:00
Michael Angerman
b093d5d10d
clean up nu-cmd-lang Cargo.toml (#8252)
Remove all un-used dependencies in nu-cmd-lang's Cargo.toml
2023-02-27 21:56:21 -08:00
Antoine Stevan
9e589a9d93
FEATURE: add the first draft of the standard library (#8150)
hello there 👋 😋 

as discussed over on the discord server, in `#standard-library`, there
is this new project of putting together a bunch of "_standard_" scripts
and functions and propose a `nushell` "_standard library_".
this PR is the first one in that direction 🎉 

> **Note**
> ~~this PR is still a draft to have some feedback 😌~~ 
> this PR is now **READY FOR REVIEW** 🎉 

# Description
this PR implements the following few commands:
- the `assert` familly with a private helper `_assert`
- a version of the `match` statement

i've also added some examples in the docstrings of the functions 👍 

# User-Facing Changes
the standard library can now be used with
```bash
use crates/nu-utils/src/sample_config/std.nu
```
from the root of the `nushell` source

# Tests + Formatting
i've written a first draft of a
[`tests.nu`](https://github.com/amtoine/nushell/blob/feature/first-draft-of-the-standard-library/crates/nu-utils/src/sample_config/tests.nu)
module which
- tests the `assert` familly of function in `test_assert`
- tests the rest of the standard library in `tests`

the tests are run with
```bash
nu crates/nu-utils/src/sample_config/tests.nu
```
through the `main` function and should give no error 👍 

> **Note**
> if you change one of the test line, there should be an error popping
when running the tests 😉

# After Submitting
> **Warning**
> to be coming
2023-02-27 17:52:47 -06:00
Michael Angerman
f8d2bff283
cratification: Example support (#8231)
# Description

When the crate nu_cmd_lang crate was created last week example_test.rs
was copied over from nu_command
to nu_cmd_lang. By doing this there was a set of methods in
example_test.rs that existed in both crates...

This PR removes the redundancy by moving all of those duplicated methods
into the crate nu_test_support in a newly created file called
example_support.rs


_(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.)_

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-27 13:58:56 -08:00
mike
0a2e711351
fix: allow subtraction of durations from dates (#8247)
`date` - `duration` is
[implemented](ba5258d716/crates/nu-protocol/src/value/mod.rs (L2145))
but the type checker rejects it

this pr fixes that
2023-02-27 21:17:58 +01:00
baehyunsol
ba5258d716
remove unnecessary rows in into datetime --list (#8243)
Below is the result of `into datetime --list | uniq -d`.

```
╭───┬───────────────┬─────────┬───────────────────────────────────────╮
│ # │ Specification │ Example │              Description              │
├───┼───────────────┼─────────┼───────────────────────────────────────┤
│ 0 │ %Y            │ 2023    │ The full proleptic Gregorian year,    │
│   │               │         │ zero-padded to 4 digits.              │
│ 1 │ %C            │ 20      │ The proleptic Gregorian year divided  │
│   │               │         │ by 100, zero-padded to 2 digits.      │
╰───┴───────────────┴─────────┴───────────────────────────────────────╯
```

It's supposed to be an empty table, but it has two rows. I removed the
duplicates.

# User-Facing Changes

`into datetime --list` will print out a correct table.
2023-02-27 11:21:52 +01:00
dependabot[bot]
c358400351
Bump procfs from 0.14.1 to 0.15.1 (#8233)
Bumps [procfs](https://github.com/eminence/procfs) from 0.14.1 to
0.15.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/eminence/procfs/releases">procfs's
releases</a>.</em></p>
<blockquote>
<h2>v0.15.1</h2>
<h2>New features</h2>
<ul>
<li>Change Stat::comm documentation by <a
href="https://github.com/rust1248"><code>@​rust1248</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/251">eminence/procfs#251</a></li>
<li>Add docs and a as_str method to MMPermission by <a
href="https://github.com/eminence"><code>@​eminence</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/252">eminence/procfs#252</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/rust1248"><code>@​rust1248</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/251">eminence/procfs#251</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/eminence/procfs/compare/v0.15.0...v0.15.1">https://github.com/eminence/procfs/compare/v0.15.0...v0.15.1</a></p>
<h2>v0.15.0</h2>
<h2>New Features</h2>
<ul>
<li>Add /proc/iomem by <a
href="https://github.com/tatref"><code>@​tatref</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/216">eminence/procfs#216</a></li>
<li>Add new functions to read various net files for a specific process
by <a href="https://github.com/eminence"><code>@​eminence</code></a> in
<a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/226">eminence/procfs#226</a></li>
<li>add /proc/kpageflags by <a
href="https://github.com/tatref"><code>@​tatref</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/233">eminence/procfs#233</a></li>
<li>Enable oppportunistic fd counting fast path by <a
href="https://github.com/bobrik"><code>@​bobrik</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/234">eminence/procfs#234</a></li>
<li>add /proc/kpagecount by <a
href="https://github.com/tatref"><code>@​tatref</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/232">eminence/procfs#232</a></li>
<li>Add new <code>/proc/meminfo</code> fields. by <a
href="https://github.com/afranchuk"><code>@​afranchuk</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/238">eminence/procfs#238</a></li>
<li>impl Hash for kernel version by <a
href="https://github.com/tatref"><code>@​tatref</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/240">eminence/procfs#240</a></li>
</ul>
<h2>Bug fixes</h2>
<ul>
<li>fix chrono::Local::timestamp deprecated in chrono 0.4.23 by <a
href="https://github.com/tatref"><code>@​tatref</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/220">eminence/procfs#220</a></li>
<li>Fix some minor documentation issues by <a
href="https://github.com/eminence"><code>@​eminence</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/225">eminence/procfs#225</a></li>
<li>Fixes the reported path when a task's function returns an error by
<a href="https://github.com/eminence"><code>@​eminence</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/230">eminence/procfs#230</a></li>
<li>fix shm size type by <a
href="https://github.com/tatref"><code>@​tatref</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/243">eminence/procfs#243</a></li>
</ul>
<h2>Breaking changes</h2>
<ul>
<li>ticks_per_second and page_size are infallible by <a
href="https://github.com/eminence"><code>@​eminence</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/235">eminence/procfs#235</a></li>
<li>parse uid for /proc/net/{tcp,udp} by <a
href="https://github.com/trinity-1686a"><code>@​trinity-1686a</code></a>
in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/231">eminence/procfs#231</a></li>
<li>Refactor and expose memory map processing. by <a
href="https://github.com/afranchuk"><code>@​afranchuk</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/237">eminence/procfs#237</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/trinity-1686a"><code>@​trinity-1686a</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/231">eminence/procfs#231</a></li>
<li><a href="https://github.com/afranchuk"><code>@​afranchuk</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/238">eminence/procfs#238</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/eminence/procfs/compare/v0.14.2...v0.15.0">https://github.com/eminence/procfs/compare/v0.14.2...v0.15.0</a></p>
<h2>MSRV Note</h2>
<p>This <code>v0.15</code> release is only tested against the latest
stable rust compiler, but is known to work with older versions (down to
rust 1.48). Support for these older compilers may break in
<code>procfs</code> patch releases. See also <a
href="https://github-redirect.dependabot.com/eminence/procfs/issues/223">#223</a></p>
<h2>v0.14.2</h2>
<h2>New Features</h2>
<ul>
<li>Process: Namespace: Use openat instead of building a path by <a
href="https://github.com/arilou"><code>@​arilou</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/192">eminence/procfs#192</a></li>
<li>add serde serialize/deserialize derives for public types by <a
href="https://github.com/eliad-wiz"><code>@​eliad-wiz</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/193">eminence/procfs#193</a></li>
<li>Disabling default features on the <code>chrono</code> crate by <a
href="https://github.com/Will-Low"><code>@​Will-Low</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/210">eminence/procfs#210</a></li>
<li>Implement smaps_rollup by <a
href="https://github.com/TaborKelly"><code>@​TaborKelly</code></a> in <a
href="https://github-redirect.dependabot.com/eminence/procfs/pull/214">eminence/procfs#214</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="16ccc15aa1"><code>16ccc15</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/eminence/procfs/issues/253">#253</a>
from eminence/v0_15_1</li>
<li><a
href="4b5b61a89d"><code>4b5b61a</code></a>
Version 0.15.1</li>
<li><a
href="b7f66d5a8c"><code>b7f66d5</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/eminence/procfs/issues/252">#252</a>
from eminence/mmperms</li>
<li><a
href="af961235ff"><code>af96123</code></a>
Add docs and a as_str method to MMPermission</li>
<li><a
href="6c6ddbd42e"><code>6c6ddbd</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/eminence/procfs/issues/251">#251</a>
from rust1248/task/fix-comm-docs</li>
<li><a
href="7e7afab4f8"><code>7e7afab</code></a>
Change Stat::comm documentation</li>
<li><a
href="391bd13a0a"><code>391bd13</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/eminence/procfs/issues/247">#247</a>
from eminence/statat_nofollow</li>
<li><a
href="d0a7c09304"><code>d0a7c09</code></a>
Don't use SYMLINK_NOFOLLOW in a statat call</li>
<li><a
href="940c163242"><code>940c163</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/eminence/procfs/issues/248">#248</a>
from eminence/criterion_update</li>
<li><a
href="0e31f6c8ee"><code>0e31f6c</code></a>
Update criterion dev-depencency</li>
<li>Additional commits viewable in <a
href="https://github.com/eminence/procfs/compare/v0.14.1...v0.15.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=procfs&package-manager=cargo&previous-version=0.14.1&new-version=0.15.1)](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 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>
Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2023-02-27 20:53:01 +13:00
Jakub Žádník
a3f817d71b
Re-implement aliases (#8123)
# Description

This PR adds an alternative alias implementation. Old aliases still work
but you need to use `old-alias` instead of `alias`.

Instead of replacing spans in the original code and re-parsing, which
proved to be extremely error-prone and a constant source of panics, the
new implementation creates a new command that references the old
command. Consider the new alias defined as `alias ll = ls -l`. The
parser creates a new command called `ll` and remembers that it is
actually a `ls` command called with the `-l` flag. Then, when the parser
sees the `ll` command, it will translate it to `ls -l` and passes to it
any parameters that were passed to the call to `ll`. It works quite
similar to how known externals defined with `extern` are implemented.

The new alias implementation should work the same way as the old
aliases, including exporting from modules, referencing both known and
unknown externals. It seems to preserve custom completions and pipeline
metadata. It is quite robust in most cases but there are some rough
edges (see later).

Fixes https://github.com/nushell/nushell/issues/7648,
https://github.com/nushell/nushell/issues/8026,
https://github.com/nushell/nushell/issues/7512,
https://github.com/nushell/nushell/issues/5780,
https://github.com/nushell/nushell/issues/7754

No effect: https://github.com/nushell/nushell/issues/8122 (we might
revisit the completions code after this PR)

Should use custom command instead:
https://github.com/nushell/nushell/issues/6048

# User-Facing Changes

Since aliases are now basically commands, it has some new implications:

1. `alias spam = "spam"` (requires command call)
	* **workaround**: use `alias spam = echo "spam"`
2. `def foo [] { 'foo' }; alias foo = ls -l` (foo defined more than
once)
* **workaround**: use different name (commands also have this
limitation)
4. `alias ls = (ls | sort-by type name -i)`
* **workaround**: Use custom command. _The common issue with this is
that it is currently not easy to pass flags through custom commands and
command referencing itself will lead to stack overflow. Both of these
issues are meant to be addressed._
5. TODO: Help messages, `which` command, `$nu.scope.aliases`, etc.
* Should we treat the aliases as commands or should they be separated
from regular commands?
6. Needs better error message and syntax highlight for recursed alias
(`alias f = f`)
7. Can't create alias with the same name as existing command (`alias ls
= ls -a`)
	* Might be possible to add support for it (not 100% sure)
8. Standalone `alias` doesn't list aliases anymore
9. Can't alias parser keywords (e.g., stuff like `alias ou = overlay
use` won't work)
	* TODO: Needs a better error message when attempting to do so

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-27 20:44:05 +13:00
Gustavo Maia
c6e2607868
Add Remove welcome message tutorial (#8217)
# Description

Added message sending to docs to how to remove message tutorial:

![welcome
message](https://user-images.githubusercontent.com/67283753/221384655-9218c256-b4d6-44e5-95c6-68c50c235cb7.png)



# User-Facing Changes

- Easy to find how to remove Welcome Message


Fixes #8216  issue
2023-02-27 19:49:50 +13:00
dependabot[bot]
a09aaf3495
Bump csv from 1.1.6 to 1.2.0 (#8235)
Bumps [csv](https://github.com/BurntSushi/rust-csv) from 1.1.6 to 1.2.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fa01b78533"><code>fa01b78</code></a>
1.2.0</li>
<li><a
href="2ba20b55d9"><code>2ba20b5</code></a>
readme: various updates</li>
<li><a
href="521294f87b"><code>521294f</code></a>
msrv: set rust-version = 1.60</li>
<li><a
href="31c8ebc49d"><code>31c8ebc</code></a>
readme: updates and set rust-version</li>
<li><a
href="a0e83883e2"><code>a0e8388</code></a>
deps: drop 'bstr'</li>
<li><a
href="9e1126a3f4"><code>9e1126a</code></a>
cargo: update some fields</li>
<li><a
href="d7a4f7dcc6"><code>d7a4f7d</code></a>
rust: move to 2021 edition</li>
<li><a
href="022ac05205"><code>022ac05</code></a>
error: drop 'source' impl</li>
<li><a
href="9ab83111a7"><code>9ab8311</code></a>
*: better import grouping and short hand struct init</li>
<li><a
href="ea0273c531"><code>ea0273c</code></a>
*: fix all warnings and update code</li>
<li>Additional commits viewable in <a
href="https://github.com/BurntSushi/rust-csv/compare/1.1.6...1.2.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=csv&package-manager=cargo&previous-version=1.1.6&new-version=1.2.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 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>
2023-02-27 19:48:51 +13:00
dependabot[bot]
ffc8e752a5
Bump bytesize from 1.1.0 to 1.2.0 (#8236)
Bumps [bytesize](https://github.com/hyunsik/bytesize) from 1.1.0 to
1.2.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/hyunsik/bytesize/releases">bytesize's
releases</a>.</em></p>
<blockquote>
<h2>Release 1.2.0</h2>
<h2>Changes</h2>
<ul>
<li>serde improvements <a
href="https://github-redirect.dependabot.com/hyunsik/bytesize/issues/29">#29</a>
(<a
href="https://github.com/joeroback"><code>@​joeroback</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="476dc867b2"><code>476dc86</code></a>
Remove -dev suffix for release</li>
<li><a
href="eaaf3bc097"><code>eaaf3bc</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/hyunsik/bytesize/issues/29">#29</a>
from joeroback/serde_improvements</li>
<li><a
href="c7a785bd2c"><code>c7a785b</code></a>
resolves <a
href="https://github-redirect.dependabot.com/hyunsik/bytesize/issues/27">#27</a>,
fixes several clippy warnings with u16/u8 and is_digit/is_ascii...</li>
<li><a
href="db44636f05"><code>db44636</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/hyunsik/bytesize/issues/28">#28</a>
from ileixe/master</li>
<li><a
href="58cf4a5024"><code>58cf4a5</code></a>
Change as_u64() to const</li>
<li><a
href="065c00b54f"><code>065c00b</code></a>
Change the crate version to 1.2.0-dev</li>
<li>See full diff in <a
href="https://github.com/hyunsik/bytesize/compare/v1.1.0...v1.2.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=bytesize&package-manager=cargo&previous-version=1.1.0&new-version=1.2.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 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>
2023-02-27 19:48:14 +13:00
dependabot[bot]
6ca07b87b9
Bump sysinfo from 0.27.7 to 0.28.0 (#8237)
Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.27.7
to 0.28.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md">sysinfo's
changelog</a>.</em></p>
<blockquote>
<h1>0.28.0</h1>
<ul>
<li>Linux: Fix name and CPU usage for processes tasks.</li>
<li>unix: Keep all users, even &quot;not real&quot; accounts.</li>
<li>Windows: Use SID for Users ID.</li>
<li>Fix C API.</li>
<li>Disable default cdylib compilation.</li>
<li>Add <code>serde</code> feature to enable serialization.</li>
<li>Linux: Handle <code>Idle</code> state in
<code>ProcessStatus</code>.</li>
<li>Linux: Add brand and name of ARM CPUs.</li>
</ul>
<h1>0.27.8</h1>
<ul>
<li>macOS: Fix overflow when computing CPU usage.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/GuillaumeGomez/sysinfo/commits">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sysinfo&package-manager=cargo&previous-version=0.27.7&new-version=0.28.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 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>
2023-02-27 19:47:59 +13:00
David Matos
96e3a3de68
Error out when Select gets same row (#8200)
# Description
Fixes #8145, by disallowing any rows that are duplicated.

```
❯ ls | select 0 0
Error: 
  × Select only allows unique rows
   ╭─[entry #1:1:1]
 1 │ ls | select 0 0
   ·               ┬
   ·               ╰── duplicated row
   ╰────

```

# User-Facing 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:

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [X] `cargo test --workspace` to check that all tests pass

# 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: Reilly Wood <reilly.wood@icloud.com>
2023-02-26 18:14:15 -08:00
Reilly Wood
2aa5c2c41f
Simplify str trim command (#8205)
### What?

This change removes 3 flags (`--all`, `--both`, and `--format`) from
`str trim`. This is a net reduction of ~450 LoC and `str trim` no longer
depends on `fancy_regex`.

### Why?

I found these flags to be quite confusing when reviewing `str trim`
earlier today:

1. `--all` removes characters even if they're in the centre of the the
string.
- This is arguably not "trimming"! In all programming languages I'm
familiar with, trimming only affects the start and end of a string.
    - If someone needs to do this, `str replace` is more natural IMO
2. `--both` trims from the left and right
- Confusing and unnecessary given that this is also the default
behaviour
3. `--format` replaces multiple spaces with a single space, even in the
centre of the string
- Again, I don't think this falls under the scope of "trimming". IMO
`str replace` is a more natural fit

I believe that `str trim` is simpler and easier to understand after this
change.

### Before

```
〉help str trim
Trim whitespace or specific character

Search terms: whitespace, strip, lstrip, rstrip

Usage:
  > str trim {flags} ...(rest)

Flags:
  -h, --help - Display the help message for this command
  -c, --char <String> - character to trim (default: whitespace)
  -l, --left - trims characters only from the beginning of the string
  -r, --right - trims characters only from the end of the string
  -a, --all - trims all characters from both sides of the string *and* in the middle
  -b, --both - trims all characters from left and right side of the string
  -f, --format - trims spaces replacing multiple characters with singles in the middle
```

### After

```
〉help str trim
Trim whitespace or specific character

Search terms: whitespace, strip, lstrip, rstrip

Usage:
  > str trim {flags} ...(rest)

Flags:
  -h, --help - Display the help message for this command
  -c, --char <String> - character to trim (default: whitespace)
  -l, --left - trims characters only from the beginning of the string
  -r, --right - trims characters only from the end of the string
```
2023-02-26 12:23:30 -08:00
Xoffio
4b3e3a37a3
Ctrl+c interruption - cp command (#8219)
# Description
if you try to copy a big file with `cp` you will noticed that you can't
interrupt the process. This pull request fix that.
This was discuss here
https://github.com/nushell/nushell/pull/8012#issuecomment-1427313054

# User-Facing Changes
None

# Tests + Formatting
- Check - `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- Check - `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect` to check that you're
using the standard code style
- Check -  `cargo test --workspace` to check that all tests pass

---------

Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
2023-02-26 12:18:20 -08:00
Antoine Stevan
2492165fcb
FEATURE: print example command results in the help (#8189)
Should close #8035.

> **Note**
> this is my first technical PR for `nushell`
> - i might very well miss things
> - i tried to be as complete as possible about the changes
> - please require further changes if i did something wrong, i'm open to
any remark 😌

# Description
this PR adds, when it is defined in the `examples` method of the
`Command` implementations, the output of the examples to the output of
the `help` command.

this PR
- only modifies `crates/nu-engine/src/documentation.rs` and the
`get_documentation` function
- defines a new `WD` constant to print a **W**hite **D**immed `...`
- a `match` statement at the end of the example loop to
- print a white dimmed `...` when the example is not set, i.e. set to
`None` in the `examples` method of the `Command` implementation of a
command
- pretty print the output of the associated example `Value` when it has
been defined

> **Warning**
> LIMITATIONS:
> - i use snippets from `crates/nu-protocol/src/pipeline_data.rs`
> - the table creation from `pub PipelineData::print`, i.e. the `let
decl_id = ...;` and `let table = ...;` in the change
> - the table item printing from `PipelineData::write_all_and_flush`,
i.e. the `for item in table { ... }`
>
> ADDRESSED:
> - ~~the formatting of the output is not perfect and has to be fully
left aligned with the first column for now~~ (fixed with
[`5abeefd558c34ba9bae15e2f183ff4625442921e`..`a62be1b5a2c730959da5dbc028bb91ffe5093f63`](5abeefd558c34ba9bae15e2f183ff4625442921e..a62be1b5a2c730959da5dbc028bb91ffe5093f63))
> - ~~i'm using `.unwrap()` on both the changes above, not sure how to
handle this for now~~ (fixed for now thanks to 49f1dc080)
> - ~~the tests and `clippy` checks do not pass for now, see below~~
(`clippy` now is happy with 49f1dc080 and the tests pass with
11666bc715)

# User-Facing Changes
the output of the `help <command>` command is now augmented with the
outputs of the examples, when they are defined.
- `with-env`
```bash
> help with-env
...
Examples:
  Set the MYENV environment variable
  > with-env [MYENV "my env value"] { $env.MYENV }
  my env value

  Set by primitive value list
  > with-env [X Y W Z] { $env.X }
  Y

  Set by single row table
  > with-env [[X W]; [Y Z]] { $env.W }
  Z

  Set by key-value record
  > with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
  ╭───┬───╮
  │ 0 │ Y │
  │ 1 │ Z │
  ╰───┴───╯
```
instead of the previous
```bash
> help with-env
...
Examples:
  Set the MYENV environment variable
  > with-env [MYENV "my env value"] { $env.MYENV }

  Set by primitive value list
  > with-env [X Y W Z] { $env.X }

  Set by single row table
  > with-env [[X W]; [Y Z]] { $env.W }

  Set by key-value record
  > with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
```
- `merge`
```bash
> help merge
...
Examples:
  Add an 'index' column to the input table
  > [a b c] | wrap name | merge ( [1 2 3] | wrap index )
  ╭───┬──────╮
  │ # │ name │
  ├───┼──────┤
  │ 1 │ a    │
  │ 2 │ b    │
  │ 3 │ c    │
  ╰───┴──────╯

  Merge two records
  > {a: 1, b: 2} | merge {c: 3}
  ╭───┬───╮
  │ a │ 1 │
  │ b │ 2 │
  │ c │ 3 │
  ╰───┴───╯

  Merge two tables, overwriting overlapping columns
  > [{columnA: A0 columnB: B0}] | merge [{columnA: 'A0*'}]
  ╭───┬─────────┬─────────╮
  │ # │ columnA │ columnB │
  ├───┼─────────┼─────────┤
  │ 0 │ A0*     │ B0      │
  ╰───┴─────────┴─────────╯
```
instead of the previous
```bash
> help merge
...
Examples:
  Add an 'index' column to the input table
  > [a b c] | wrap name | merge ( [1 2 3] | wrap index )

  Merge two records
  > {a: 1, b: 2} | merge {c: 3}

  Merge two tables, overwriting overlapping columns
  > [{columnA: A0 columnB: B0}] | merge [{columnA: 'A0*'}]
```
2023-02-26 21:05:11 +01:00
Doru
c602b5a1e8
special-case ExternalStream in bytes starts-with (#8203)
# Description
`bytes starts-with` converts the input into a `Value` before running
.starts_with to find if the binary matches. This has two side effects:
it makes the code simpler, only dealing in whole values, and simplifying
a lot of input pipeline handling and value transforming it would
otherwise have to do. _Especially_ in the presence of a cell path to
drill into. It also makes buffers the entire input into memory, which
can take up a lot of memory when dealing with large files, especially if
you only want to check the first few bytes (like for a magic number).

This PR adds a special branch on PipelineData::ExternalStream with a
streaming version of starts_with.

# User-Facing Changes
Opening large files and running bytes starts-with on them will not take
a long time.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# Drawbacks
Streaming checking is more complicated, and there may be bugs. I tested
it with multiple chunks with string data and binary data and it seems to
work alright up to 8k and over bytes, though.

The existing `operate` method still exists because the way it handles
cell paths and values is complicated. This causes some "code
duplication", or at least some intent duplication, between the value
code and the streaming code. This might be worthwhile considering the
performance gains (approaching infinity on larger inputs).

Another thing to consider is that my ExternalStream branch considers
string data as valid input. The operate branch only parses Binary
values, so it would fail. `open` is kind of unpredictable on whether it
returns string data or binary data, even when passing `--raw`. I think
this can be a problem but not really one I'm trying to tackle in this
PR, so, it's worth considering.
2023-02-26 15:17:44 +01:00
pwygab
9bbb9711e4
allow for arguments in EDITOR and VISUAL env vars (#8105)
# Description

Fixes #8051.

# User-Facing Changes

You can now put command arguments into the EDITOR and VISUAL config /
env variables.

# Tests + Formatting

I don't know how to write tests for this. However, I set $env.EDITOR to
"nvim -R" and it seemed to work.

# 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.
2023-02-26 06:56:38 -06:00
Antoine Stevan
680405e527
REFACTOR: format some example commands (#8223)
hellord 👋 😋 

# Description
this PR fixes the format of a few single-line examples and the
indentation of some multi-line examples
- single-line example formatting
  - `compact`
- multi-line example indentation
  - `update cells`
  - `error make
  - `split-by`

# User-Facing Changes
- `compact`

from
```bash
Examples:
  Filter out all records where 'Hello' is null (returns nothing)
  > [["Hello" "World"]; [null 3]]| compact Hello

  Filter out all records where 'World' is null (Returns the table)
  > [["Hello" "World"]; [null 3]]| compact World
```
to
```bash
Examples:
  Filter out all records where 'Hello' is null (returns nothing)
  > [["Hello" "World"]; [null 3]] | compact Hello

  Filter out all records where 'World' is null (Returns the table)
  > [["Hello" "World"]; [null 3]] | compact World
```
- `update cells`

from
```bash
Examples:
  Update the zero value cells to empty strings.
  > [
    ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
    [          37,            0,            0,            0,           37,            0,            0]
] | update cells { |value|
      if $value == 0 {
        ""
      } else {
        $value
      }
}

  Update the zero value cells to empty strings in 2 last columns.
  > [
    ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
    [          37,            0,            0,            0,           37,            0,            0]
] | update cells -c ["2021-11-18", "2021-11-17"] { |value|
        if $value == 0 {
          ""
        } else {
          $value
        }
}
```
to
```bash
Examples:
  Update the zero value cells to empty strings.
  > [
        ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
        [          37,            0,            0,            0,           37,            0,            0]
    ] | update cells { |value|
          if $value == 0 {
            ""
          } else {
            $value
          }
    }

  Update the zero value cells to empty strings in 2 last columns.
  > [
        ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
        [          37,            0,            0,            0,           37,            0,            0]
    ] | update cells -c ["2021-11-18", "2021-11-17"] { |value|
            if $value == 0 {
              ""
            } else {
              $value
            }
    }
```
- `split-by`

from
```bash
Examples:
  split items by column named "lang"
  >
                {
                    '2019': [
                      { name: 'andres', lang: 'rb', year: '2019' },
                      { name: 'jt', lang: 'rs', year: '2019' }
                    ],
                    '2021': [
                      { name: 'storm', lang: 'rs', 'year': '2021' }
                    ]
                } | split-by lang
```
to
```bash
Examples:
  split items by column named "lang"
  > {
        '2019': [
          { name: 'andres', lang: 'rb', year: '2019' },
          { name: 'jt', lang: 'rs', year: '2019' }
        ],
        '2021': [
          { name: 'storm', lang: 'rs', 'year': '2021' }
        ]
    } | split-by lang
```
- `error make`

from
```bash
Examples:
  Create a custom error for a custom command
  > def foo [x] {
      let span = (metadata $x).span;
      error make {msg: "this is fishy", label: {text: "fish right here", start: $span.start, end: $span.end } }
    }

  Create a simple custom error for a custom command
  > def foo [x] {
      error make {msg: "this is fishy"}
    }
```
to
```bash
Examples:
  Create a custom error for a custom command
  > def foo [x] {
        let span = (metadata $x).span;
        error make {msg: "this is fishy", label: {text: "fish right here", start: $span.start, end: $span.end } }
    }

  Create a simple custom error for a custom command
  > def foo [x] {
        error make {msg: "this is fishy"}
    }
```

# Tests + Formatting
no tests have been changed => this is a pure formatting PR

- ✔️ `cargo fmt --all`
- ✔️ `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- ✔️ `cargo test --workspace`

# After Submitting
need to change the book? 🤔
2023-02-26 06:50:05 -06:00
pwygab
44595b44c5
add case insensitive switch to starts-with and ends-with (#8221)
# Description

Fixes #8202

# User-Facing Changes
`str starts-with` and `str ends-with` now has a `-i` switch.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-26 06:48:09 -06:00
Stefan Holderbach
b27c7702f9
Test more datatypes in nuon (#8211)
# Description

While working on #8210 I noticed that we did not explicitly check a
number of `Value` variants for proper serialization and deserialization.


- Test filesize in `to/from nuon`
- Test duration in `from/to nuon`
- Test datetime in `from/to nuon`
- Test graceful failure of closure in `to nuon`


# User-Facing Changes

(-)

# Tests + Formatting

All about them tests
2023-02-25 19:26:34 +01:00
Kovacsics Robert
378a3ae05f
Use with-env to avoid calling external command on invalid command (#8209)
# Description

My terminal emulator happens to be called `st`
(https://st.suckless.org/) which breaks these tests for me

_(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.)_

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-25 09:36:51 -08:00
Stefan Holderbach
836a56b347
Revert range expansion for to nuon (#8210)
# Description

The code to generate the nuon format supports writing range literals,
which obviates the need to expand the range as added in #8047

# User-Facing Changes

`to nuon` will still output ranges as literals

# Tests + Formatting

- Add test for `to nuon` range output
- Add `from nuon` test for range
2023-02-25 18:29:30 +01:00
baehyunsol
b1e7bb899a
Update trim_.rs (#8201)
fix typo in help messages


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

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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: Reilly Wood <reilly.wood@icloud.com>
2023-02-24 22:18:20 -08:00
alesito85
7c285750c7
Fixes autocomplete when using sudo (#8094)
# Description

This PR addresses issue #2047 in order to enable autocomplete
functionality when using sudo for executing commands. I'e done a couple
of auxiliary checks such as ignoring whitespace and the last pipe in
order to determine the last command.

# User-Facing Changes

The only user facing change should be the autocomplete working.

# Tests + Formatting

All tests and formatting pass.

# Screenshots

<img width="454" alt="image"
src="https://user-images.githubusercontent.com/4399118/219404037-6cce4358-68a9-42bb-a09b-2986b10fa6cc.png">

# Suggestions welcome

I still don't know the in's and out's if nushell very well, any
suggestions for improvements are welcome.
2023-02-24 15:05:36 -08:00
Jakub Žádník
e93a8b1d32
Move profiling metadata collecting to function (#8198) 2023-02-25 00:29:07 +02:00
David Matos
42f0b55de0
allow Range to expand to array-like when converting to json (#8047)
# Description
Fixes #8002, which expands ranges `1..3` to expand to array-like when
saving and converting to json. Now,

```
> 1..3 | save foo.json
# foo.json
[
    1,
    2,
    3
]


> 1..3 | to json
[
    1,
    2,
    3
]
```
# 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:

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [X] `cargo test --workspace` to check that all tests pass

# 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.
2023-02-24 15:31:33 -06:00
Henry Jetmundsen
253b223e65
pipe binary data to external commands (#8058)
Fixes #7615 

# Description

When calling external commands, we create a table from the pipeline data
to handle external commands expecting paginated input. When a binary
value is made into a table, we convert the vector of bytes representing
the binary bytes into a pretty formatted string. This results in the
pretty formatted string being sent to external commands instead of the
actual binary bytes. By checking whether the stdout of the call is being
redirected, we can decide whether to send the raw binary bytes or the
pretty formatted output when creating a table command.

# User-Facing Changes

When passing binary values to external commands, the external command
will receive the actual bytes instead of the pretty printed string. Use
cases that don't involve piping a binary value into an external command
are unchanged.


![new_behavior](https://user-images.githubusercontent.com/32406734/218349172-24cd12f2-d563-4957-bdf1-6aa804b174b2.png)

# 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 -A
clippy::needless_collect to check that you're using the standard code
style
    cargo test --workspace to check that all tests pass

# 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.
2023-02-24 21:39:52 +01:00
Alex Tremblay
4dd9d0d46b
move hash md5 and hash sha256 commands to the hash category (#8196)
# Description

For auto-generated documentation, move the `hash _` commands into the
Hash category

# User-Facing Changes

Apart from documentation, none.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-24 11:53:25 -06:00
Darren Schroeder
fd1ac5106d
fix ansi example so it is tested (#8192)
# Description

This PR just fixes one `ansi` test so that the test runner will accept
it and test the scenario. No other changes.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-24 11:52:51 -06:00
Ryan Devenney
b572b4ecbd
remove links to ShellError and ParseError docs - #8167 (#8193)
# Description

issue #8167

Remove the `(link)` to the docs for `ShellError` and `ParseError`. As
per discussion on the issue, the nu-parser version didn't update on the
docs causing deadlinks for those errors, which brought the usefullness
of these links into question and it was decided to remove all of them
that `derive(diagnostic)`.

# User-Facing Changes
Before:
```
/home/rdevenney/projects/open_source/nushell〉ls | get name}
Error: nu::parser::unbalanced_delimiter (link)

  × Unbalanced delimiter.
   ╭─[entry #1:1:1]
 1 │ ls | get name}
   ·              ▲
   ·              ╰── unbalanced { and }
   ╰────
```

After:
```
/home/rdevenney/projects/open_source/nushell〉ls | get name}
Error: nu::parser::unbalanced_delimiter

  × Unbalanced delimiter.
   ╭─[entry #1:1:1]
 1 │ ls | get name}
   ·              ▲
   ·              ╰── unbalanced { and }
   ╰────
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-24 09:26:31 -08:00
Michael Angerman
585e104608
Cratification: Break out nu_cmd_lang into a separate crate (#8181)
# Description

This breaks out the core_commands into a separate crate called
nu_cmd_lang

_(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.)_

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-24 09:54:42 -06:00
Jérémy Audiger
83087e0f9d
HTTP HEAD / PATCH / PUT / DELETE commands (#8144)
# Description

Based on https://github.com/nushell/nushell/pull/8135.

Add the remaining HTTP commands:

- Head
- Patch
- Put
- Delete

It should finally resolve the issue
https://github.com/nushell/nushell/issues/2741

# User-Facing Changes

New sub HTTP commands.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-23 17:52:12 -06:00
Alex Saveau
aba0fb0000
Compress $HOME into ~ in prompt (#8173) 2023-02-22 16:36:26 -06:00
WindSoilder
0e86ba4b63
Dependency update: update notify version to v5 (#8114)
# Description

Relative: #8060

While investigating, I found we need to update notify, which is a good
step to remove some duplicate dependencies.

As title, here are some goods and bads after updating:

## Good
keep dependency up to date, and remove duplidate dependency(cfg-if,
winapi) in Cargo.lock.

## Bad
Introduce some breaking changes:
After updating to notify v5, I found that we have to remove `Rename`
events.

But I've testing under notify v4, and it doesn't work good if we running
the following command on MacOS:
```
touch a
mv a b
```
It fires file create event, but no file rename event. So `rename` event
is not really reliable, so I think it's ok for us to remove `Rename`
events.

The reason to remove `--debounce-ms` flag:
It's not provided by defualt file watcher, we can use
[PollWatcher](https://docs.rs/notify/latest/notify/poll/struct.PollWatcher.html),
but it scans filesystem, which is really expensive. So I just remove the
flag.

# User-Facing Changes

1. `--debounce-ms` flag is removed
2. no longer watch `Rename` event.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 13:35:09 -08:00
Xoffio
fc23c6721a
cp progress bar implementation (#8012)
# NOTE
Clean duplicate of #7825
Sorry about all the mess guys... I got confuse with GitHub and and ended
up mankind that mess.
This the same code I just cleaned the commits.

# Description
Progress bar implementation for the `cp` command. Now if the flag `-p`
or `--progress` is set, then the user will be able to see the progress
of the file or files being copy


![progressbar_cp01](https://user-images.githubusercontent.com/38369407/213899494-0f6a4aa9-ee82-48c3-a1f1-1816f3fc1d9c.jpg)

![progressbar_cp02](https://user-images.githubusercontent.com/38369407/213899497-2f9e6e8c-fdd9-400b-bd8d-c59899ae0368.jpg)

# User-Facing Changes
A new flag (`--progress` `-p`) was added to the `cp` command 
Examples:
```nu
cp -p test_file.txt test_folder_1\
cp -r -p test_folder\* test_folder_1\
cp -r -p -i test_folder\* test_folder_1\
```

## Notes 
- The progress bar uses `std::io::{Read, Write}` instead of
`std::fs::copy` to get the progress. that means that when the progress
bar is used the copy process might be a bit slower.
- Progress bar for symbolic links TBD: Since symbolic links are usually
very light I think is not worth it to duplicate the function
`copy_symlink` just to add a progress bar that will be so fast to the
point is not needed, but.. for consistency purposes we might need to
added it, In that case I would have to pass the variable `progress` by
parameter (to not duplicate code unnecessary). If I do that i would have
to pass the `progress` var to every function to respect `copy_impl: impl
Fn(PathBuf, PathBuf, Span)`. Please let me know if this is not clear :p

---------

Co-authored-by: Reilly Wood <reilly.wood@icloud.com>
2023-02-22 11:57:38 -08:00
Yethal
f4a129a792
Added examples to query web plugin (#8171)
# 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.)_

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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: Yethal <nosuchemail@email.com>
2023-02-22 19:01:15 +00:00
Maxim Zhiburt
8deecc0137
table --collapse dont do truncation return message instead (#8172)
Reverts #8042

I've just noticed that #8042 was merged, but I didn't addressed your
@fdncred last comment.
This PR reverts #8042 and returns a message in cases where we need
truncation/wrapping.


157b7e0b60/crates/nu-command/tests/commands/table.rs (L234-L240)

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-22 18:35:45 +00:00
WindSoilder
c7966e81c2
check external failed in let assignment (#8164)
# Description

Fixes: #8136

# User-Facing Changes

The following command

```
let VAR = ^cat non-existing-file; echo "failed"
```
will no longer output `failed` message


# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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: Reilly Wood <reilly.wood@icloud.com>
2023-02-22 17:35:09 +00:00
Ryan Devenney
2659c359e9
interrupt input command with Ctrl + C (#8159)
# Description

GH Issue: [#8074](https://github.com/nushell/nushell/issues/8074)

Adding SIGINT Ctrl + C functionality to *most* of the `input` command.
`input` with the flags `--suppress-output` and `--bytes-until` are
executed in raw mode which allows a ^C signal to be caught as it's
input, but an "optionless" call of `input` is using a standard
`read_line()` method that takes a ^C input and clears the buffer of any
data collected before the ^C. I'm more than happy to alter the
"optionless" call but putting it in raw mode hides the user input, so at
the moment that's unchanged.

# User-Facing Changes

Now ^C anywhere in the stdin stream will cause the command to SIGINT (as
long as the command isn't optionless), rather than being read in as part
of the input.
```
/home/rdevenney/projects/open_source/nushell〉input --suppress-output
Error: nu:🐚:io_error (link)

  × I/O error
  help: SIGINT
```

```
/home/rdevenney/projects/open_source/nushell〉input --bytes-until "a"
Error: nu:🐚:io_error (link)

  × I/O error
  help: SIGINT

```

As mentioned above, the default input behavior is the same.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 17:19:19 +00:00
Artemiy
e389e51b2b
Display empty records and lists (#7925)
# Description

Fix some issues related to #7444 
1. Empty lists and records are now displayed as a small notice in a box:

![image](https://user-images.githubusercontent.com/17511668/215832023-3f8d743a-2899-416f-9109-7876ad2bbedf.png)

![image](https://user-images.githubusercontent.com/17511668/215832273-c737b8a4-af33-4c16-8dd3-bd4f0fd19b5a.png)
2. Empty records are now correctly displayed if inside of another record
list or table:

![image](https://user-images.githubusercontent.com/17511668/215832597-00f0cebc-a3b6-4ce8-8373-a9340d4c7020.png)

![image](https://user-images.githubusercontent.com/17511668/215832540-ab0e2a14-b8f6-4f47-976c-42003b622ef6.png)
3. Fixed inconsistent coloring of empty list placeholder inside of
lists/tables:

![image](https://user-images.githubusercontent.com/17511668/215832924-813ffe17-e04e-4301-97c3-1bdbccf1825c.png)

![image](https://user-images.githubusercontent.com/17511668/215832963-4765c4cf-3036-4bcc-81e1-ced941fa47cb.png)


# User-Facing Changes

`table` command now displays empty records and lists like a table with
text and correctly displays empty records inside tables and lists.

New behavior of displaying empty lists and records can be disabled using
`table.show_empty` config option.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 16:18:33 +00:00
Maxim Zhiburt
0ab6b66d8f
nu-table/ Fix --collapse wrap/truncate [WIP] (#8042)
close #8034

So it's actually a work around to do "our best".

We basically try 3 attemps to build a table with each time truncating
values bigger then (termwidth/2, termwidth/4, termwidth/8).

PS1: The logic is kind of not ideal need to think about it.

_______________

PS2:
I've just noticed that multi-line key behaves strangely; (not sure
whether it's caused by this wrap (unlikely))
Need to investigate this.

I'd bet it's a multiline key.


![image](https://user-images.githubusercontent.com/20165848/218267237-6b7ee9af-675a-428e-92cd-65808cec50f0.png)

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-22 14:10:17 +00:00
WindSoilder
8608d8d873
remove git completion in default config (#8087)
# Description

As title, making default config simpler, and user can get custom
completion from here:
https://github.com/nushell/nu_scripts/tree/main/custom-completions Or
using carapace
# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 13:05:21 +00:00
Ryan Devenney
d34a2c353f
files and directory completions now use ascending ordering rather than Levenshtein. #8023 (#8085)
# Description

This change sorts completions for files and directories by the ascending
ordering method, related to issue:
[#8023](https://github.com/nushell/nushell/issues/8023)

Currently the Suggestions are being sorted twice, so it's now following
the convention from `completion/base.rs` to match on the
`self.get_sort_by()` result.

# User-Facing Changes

Previously the suggestions were being sorted by the Levenshtein method:
```
/home/rdevenney/projects/open_source/nushell| cd
src/                wix/                docs/               tests/
assets/             crates/             docker/             images/
target/             benches/            pkg_mgrs/           .git/
.cargo/             .github/
```

Now when you tab for autocompletions, they show up in ascending
alphabetical order as shown below (with hidden files/folders at the
end).
```
/home/rdevenney/projects/open_source/nushell| cd
assets/             benches/            crates/             docker/
docs/               images/             pkg_mgrs/           src/
target/             tests/              wix/                .cargo/
.git/               .github/
```

And when you've already typed a bit of the path:
```
/home/rdevenney/projects/open_source/nushell| cd crates/nu
crates/nu-cli/                   crates/nu-color-config/          crates/nu-command/
crates/nu-engine/                crates/nu-explore/               crates/nu-glob/
crates/nu-json/                  crates/nu-parser/                crates/nu-path/
crates/nu-plugin/                crates/nu-pretty-hex/            crates/nu-protocol/
crates/nu-system/                crates/nu-table/                 crates/nu-term-grid/
crates/nu-test-support/          crates/nu-utils/                 crates/nu_plugin_custom_values/
crates/nu_plugin_example/        crates/nu_plugin_formats/        crates/nu_plugin_gstat/
crates/nu_plugin_inc/            crates/nu_plugin_python/         crates/nu_plugin_query/
```

And another for when there are files and directories present:
```
/home/rdevenney/projects/open_source/nushell/crates/nu-cli/src| nvim                              02/16/2023 08:22:16 AM
commands.rs          completions/         config_files.rs      eval_file.rs
lib.rs               menus/               nu_highlight.rs      print.rs
prompt.rs            prompt_update.rs     reedline_config.rs   repl.rs
syntax_highlight.rs  util.rs              validation.rs
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
[*] `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 13:03:48 +00:00
Leon
150b0b6b86
Add select extra_usage explaining relationship to get (#8146)
# Description

See title.

Also changed some misleading wording in `reject`'s help.

# User-Facing Changes

See above.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 13:00:16 +00:00
Mango The Fourth
d0e0701a88
fix: fix lexing of comments, such that a#b becomes a coherent Item (#8151)
# Description

Previously `nix run nixpkgs#hello` was lexed as `Item, Item, Item,
Comment`, however, `#hello` is *not* supposed to be a comment here and
should be parsed as part of the third `Item`.

This change introduces this behavior by not interrupting the parse of
the current token upon seeing a `#`.

Thank you so much for considering this, I think many `nix` users will be
grateful for this change and I think this will lead to more adaptation
in the ecosystem.

- closes #8137 and #6335 

# User-Facing Changes

- code like `somecode# bla` and `somecode#bla` will not be parsed as
`somecode, comment` but as `somecode#bla`, hence this is a breaking
change for all users who didn't put a space before a comment introducing
token (`#`)

# Tests + Formatting

I've added tests that cover this behavior in `test_lex.rs`

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass

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

I think this is expected behavior in most other shells, so the
documentation was lacking for not documenting the unexpected behavior
before and hence now is automatically more complete >D
2023-02-22 12:59:47 +00:00
dependabot[bot]
9088ef182e
Bump errno from 0.2.8 to 0.3.0 (#8131)
Bumps [errno](https://github.com/lambda-fairy/rust-errno) from 0.2.8 to
0.3.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/lambda-fairy/rust-errno/blob/main/CHANGELOG.md">errno's
changelog</a>.</em></p>
<blockquote>
<h1>[0.3.0] - 2023-02-12</h1>
<ul>
<li>
<p>Add haiku support
<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/42">#42</a></p>
</li>
<li>
<p>Add AIX support
<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/54">#54</a></p>
</li>
<li>
<p>Add formatting with <code>#![no_std]</code>
<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/44">#44</a></p>
</li>
<li>
<p>Switch from <code>winapi</code> to <code>windows-sys</code> <a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/55">#55</a></p>
</li>
<li>
<p>Update minimum Rust version to 1.48
<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/48">#48</a>
<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/55">#55</a></p>
</li>
<li>
<p>Upgrade to Rust 2018 edition <a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/59">#59</a></p>
</li>
<li>
<p>wasm32-wasi: Use <code>__errno_location</code> instead of
<code>feature(thread_local)</code>. <a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/pull/66">#66</a></p>
</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="e1882701f6"><code>e188270</code></a>
Release 0.3.0</li>
<li><a
href="3983d26f98"><code>3983d26</code></a>
Add <a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/issues/66">#66</a>
to changelog</li>
<li><a
href="362d7c6c35"><code>362d7c6</code></a>
Update windows-sys requirement from 0.42 to 0.45 (<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/issues/67">#67</a>)</li>
<li><a
href="b8cc39bb8d"><code>b8cc39b</code></a>
wasm32-wasi: Use <code>__errno_location</code> instead of
<code>feature(thread_local)</code>. (<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/issues/66">#66</a>)</li>
<li><a
href="dbd02cf02f"><code>dbd02cf</code></a>
Replace deprecated <code>trim_right</code> with <code>trim_end</code>
(<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/issues/65">#65</a>)</li>
<li><a
href="c999f38356"><code>c999f38</code></a>
Add comparison with <code>std::io::Error</code></li>
<li><a
href="8a4c62af22"><code>8a4c62a</code></a>
Bump actions/checkout from 2 to 3 (<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/issues/64">#64</a>)</li>
<li><a
href="04379ae703"><code>04379ae</code></a>
Add Dependabot (<a
href="https://github-redirect.dependabot.com/lambda-fairy/rust-errno/issues/63">#63</a>)</li>
<li><a
href="18e34d3895"><code>18e34d3</code></a>
Setup caching for CI</li>
<li><a
href="81c3ba4cba"><code>81c3ba4</code></a>
Run clippy in CI</li>
<li>Additional commits viewable in <a
href="https://github.com/lambda-fairy/rust-errno/compare/v0.2.8...v0.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=errno&package-manager=cargo&previous-version=0.2.8&new-version=0.3.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 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>
2023-02-22 12:56:31 +00:00
Jérémy Audiger
c4d1aa452d
Final rework for the HTTP commands (#8135)
# Description

Final rework for https://github.com/nushell/nushell/issues/2741, after
this one, we'll add for free HTTP PUT, PATCH, DELETE and HEAD.

# User-Facing Changes

We can now post data using HTTP GET. I add some examples in the output
of `http get --help` to demonstrate this new behavior.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 12:56:11 +00:00
Darren Schroeder
e761954cf0
allow different types of lists to be appended (#8157)
# Description

closes #8153

This PR allows different types of lists, like `list<string>` and
`list<any>` to be appended with the `++=` operator.

## Before

```
mut args = [ hello ("hello" | path join world)]
$args ++= [ foo bar ]
Error: nu::parser::type_mismatch (link)

  × Type mismatch during operation.
   ╭─[entry #2:1:1]
 1 │ $args ++= [ foo bar ]
   ·           ─────┬─────
   ·                ╰── expected list<any>, found list<string>
   ╰────
```

## After

```
mut args = [ hello ("hello" | path join world)]
$args ++= [ foo bar ]
$args
╭───┬─────────────╮
│ 0 │ hello       │
│ 1 │ hello\world │
│ 2 │ foo         │
│ 3 │ bar         │
╰───┴─────────────╯
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 12:53:36 +00:00
Darren Schroeder
58829e3560
fixes a def parsing bug with a default list (#8096)
# Description

This PR fixes a bug where a default list in a custom command parameter
wasn't being accepted. The reason was because it was comparing specific
types of list like `list<any>` != `list<string>`. So, this PR attempts
to fix that.

### Before

```
> def f [param: list = [one]] { echo $param }
Error: nu::parser::assignment_mismatch (link)

  × Default value wrong type
   ╭─[entry #1:1:1]
 1 │ def f [param: list = [one]] { echo $param }
   ·                      ──┬──
   ·                        ╰── default value not list<any>
   ╰────
```

### After

```
> def f [param: list = [one]] {echo $param}
> f
╭───┬─────╮
│ 0 │ one │
╰───┴─────╯
```

closes #8092 

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 12:53:11 +00:00
WindSoilder
62652cf8c1
simplify parse_expression function code. (#8149)
# Description

When reading parser code to see how it works, I found that
`parse_expression` function contains some duplicate code about function
call, we can match several values at once to simplify code

# User-Facing Changes

None

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 12:14:20 +00:00
Leon
4482862a40
Fix one error message in into string (#8163)
# Description

Fixes the following message:
```
〉(ls).0 | into string
Error: nu:🐚:cant_convert (link)

  × Can't convert to record.
   ╭─[entry #4:1:1]
 1 │ (ls).0 | into string
   ·          ─────┬─────
   ·               ╰── can't convert string to record
   ╰────
  help: try using the `to nuon` command
```

# User-Facing Changes

See above.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-22 09:05:19 +00:00
dependabot[bot]
81dd4a8450
Bump uuid from 1.2.2 to 1.3.0 (#8130)
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.2.2 to 1.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/uuid-rs/uuid/releases">uuid's
releases</a>.</em></p>
<blockquote>
<h2>1.3.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix error message. by <a
href="https://github.com/basbossink-ds"><code>@​basbossink-ds</code></a>
in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/656">uuid-rs/uuid#656</a></li>
<li>implement Arbitrary::size_hint by <a
href="https://github.com/Ekleog"><code>@​Ekleog</code></a> in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/657">uuid-rs/uuid#657</a></li>
<li>Always use hyphenated format regardless of flags by <a
href="https://github.com/KodrAus"><code>@​KodrAus</code></a> in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/658">uuid-rs/uuid#658</a></li>
<li>Update windows-sys requirement from 0.42.0 to 0.45.0 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/654">uuid-rs/uuid#654</a></li>
<li>Prepare for 1.3.0 release by <a
href="https://github.com/KodrAus"><code>@​KodrAus</code></a> in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/659">uuid-rs/uuid#659</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a
href="https://github.com/basbossink-ds"><code>@​basbossink-ds</code></a>
made their first contribution in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/656">uuid-rs/uuid#656</a></li>
<li><a href="https://github.com/Ekleog"><code>@​Ekleog</code></a> made
their first contribution in <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/pull/657">uuid-rs/uuid#657</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/uuid-rs/uuid/compare/1.2.2...1.3.0">https://github.com/uuid-rs/uuid/compare/1.2.2...1.3.0</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="573362627c"><code>5733626</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/issues/659">#659</a>
from uuid-rs/cargo/1.3.0</li>
<li><a
href="59ac047014"><code>59ac047</code></a>
prepare for 1.3.0 release</li>
<li><a
href="e010787850"><code>e010787</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/issues/654">#654</a>
from uuid-rs/dependabot/cargo/windows-sys-0.45.0</li>
<li><a
href="b90b820603"><code>b90b820</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/issues/658">#658</a>
from uuid-rs/fix/alternate-format</li>
<li><a
href="1af8269957"><code>1af8269</code></a>
fix up tests around alternative format</li>
<li><a
href="e7eaf5b4a2"><code>e7eaf5b</code></a>
always use hyphenated format regardless of flags</li>
<li><a
href="52197cd275"><code>52197cd</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/issues/657">#657</a>
from Ekleog/arbitrary-size-hint</li>
<li><a
href="b362542ee2"><code>b362542</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/uuid-rs/uuid/issues/656">#656</a>
from basbossink-ds/fix/655-deserialize-error-msg</li>
<li><a
href="212b902277"><code>212b902</code></a>
implement Arbitrary::size_hint</li>
<li><a
href="40d8711f11"><code>40d8711</code></a>
Also fix the doc comment</li>
<li>Additional commits viewable in <a
href="https://github.com/uuid-rs/uuid/compare/1.2.2...1.3.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=uuid&package-manager=cargo&previous-version=1.2.2&new-version=1.3.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 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>
2023-02-21 23:32:52 +00:00
Hofer-Julian
101ed629a4
Update polars to 0.27.2 (#8154)
Mostly to get rid of https://github.com/pola-rs/polars/pull/6098/files

This currently breaks nushell's table formatting:

```
nu ❯  open-df forcing.arrow | first
could not mmap compressed IPC file, defaulting to normal read╭───┬──────────┬────┬────────┬──────────┬───────┬──────────┬──────┬──────────┬─────╮
│ # │   time   │ id │ demand │ drainage │ E_pot │ infiltra │  P   │ priority │ ... │
│   │          │    │        │          │       │ tion     │      │          │     │
├───┼──────────┼────┼────────┼──────────┼───────┼──────────┼──────┼──────────┼─────┤
│ 0 │ 4 years  │  1 │   0.00 │     0.02 │  0.00 │     0.00 │ 0.00 │     4.00 │ ... │
│   │ ago      │    │        │          │       │          │      │          │     │
╰───┴──────────┴────┴────────┴──────────┴───────┴──────────┴──────┴──────────┴─────╯
```

@visr
2023-02-21 23:32:28 +00:00
Stefan Holderbach
95ec2fcce7
Update to 0.76.1 version for development (#8161)
# Description

For tracking in `version` for bug reports during development. Might be
used for an urgent hotfix if necessary.
2023-02-21 23:21:39 +00:00
Stefan Holderbach
73bc3389e5
Fix Cargo.toml of nu_plugin_formats (#8160)
# Description


The crate manifest didn't include vital information to publish to
crates.io

This now includes the basic description and license information
2023-02-21 22:44:52 +00:00
Stefan Holderbach
bc38a6a795
Bump version for 0.76.0 release (#8121)
Before landing:

- [x] `reedline 0.16.0` is out and pinned.
- [x] all fixes and features necessary are landed.

In the meantime:

- [ ] feed the release notes with relevant features and breaking changes
2023-02-21 20:46:29 +00:00
Antoine Stevan
e89866bedb
TEST: add the output to the new with-env example (#8148)
Related to #8119.
Should address the review comment by @sholderbach from #8119.


# Description

this PR adds the output to the new example for the `with-env` command
introduced by #8119.

```bash
with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
```
should output
```bash
["Y", "Z"]
```
hence the proposition from @sholderbach, i.e.
```rust
Some(Value::list(
    vec![Value::test_string("Y"), Value::test_string("Z")],
    Span::test_data(),
))
```

# User-Facing Changes
_none_

# Tests + Formatting

not really a test, only the output value for the last `with-env` example

- ✔️ `cargo fmt --all`
- ✔️ `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- ✔️ `cargo test --workspace`

# After Submitting
_none_
2023-02-21 10:15:35 +00:00
Stefan Holderbach
ca09dbbbee
Pin reedline to 0.16.0 (#8142)
# Description

See release notes:
https://github.com/nushell/reedline/releases/tag/v0.16.0

# User-Facing Changes

Only internal

# Tests + Formatting

(-)
2023-02-20 21:44:04 +00:00
Darren Schroeder
6ca62ef131
show more informaiton when there are toml errors (#8140)
# Description

While debugging #8139 I noticed that there was some error information
coming from the toml crate that we were not displaying. This would've
helped me to understand what was going on. So, this PR shows more
verbose errors when toml fails to parse.

### Before

```
cargo llvm-cov show-env | from toml 
Error: nu:🐚:cant_convert (link)

  × Can't convert to structured toml data.
   ╭─[entry #1:1:1]
 1 │ cargo llvm-cov show-env | from toml
   · ──┬──
   ·   ╰── can't convert string to structured toml data
   ╰────
```

### After

```
cargo llvm-cov show-env | from toml
Error: nu:🐚:cant_convert (link)

  × Can't convert to structured toml data.
   ╭─[entry #1:1:1]
 1 │ cargo llvm-cov show-env | from toml
   · ──┬──
   ·   ╰── can't convert string to structured toml data
   ╰────
  help: TOML parse error at line 2, column 24
          |
        2 | LLVM_PROFILE_FILE="C:\CarTar\nushell-%p-%m.profraw"
          |                        ^
        invalid escape sequence
        expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
```

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-20 18:50:31 +00:00
WindSoilder
8e84e33638
add usage for plugin commands (#8138)
# Description

As title

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-20 15:03:17 +00:00
Maxim Zhiburt
b9be416937
Add colors in table --collapse (#8120)
close #8110 

cc: @amtoine

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-20 12:59:33 +00:00
Bob Hyman
0a8c9b22b0
string | fill counts clusters, not graphemes; and doesn't count ANSI escape codes (#8134)
Enhancement of new `fill` command (#7846) to handle content including
ANSI escape codes for formatting or multi-code-point Unicode grapheme
clusters.
In both of these cases, the content is (many) bytes longer than its
visible length, and `fill` was counting the extra bytes so not adding
enough fill characters.

# Description

This script:
```rust
# the teacher emoji `\u{1F9D1}\u{200D}\u{1F3EB}` is 3 code points, but only 1 print position wide.
echo "This output should be 3 print positions wide, with leading and trailing `+`"
$"\u{1F9D1}\u{200D}\u{1F3EB}" | fill -c "+" -w 3 -a "c"

echo "This output should be 3 print positions wide, with leading and trailing `+`"
$"(ansi green)a(ansi reset)" | fill -c "+" -w 3 -a c
echo ""
```

Was producing this output:
```rust
This output should be 3 print positions wide, with leading and trailing `+`
🧑‍🏫

This output should be 3 print positions wide, with leading and trailing `+`
a
```

After this PR, it produces this output:
```rust
This output should be 3 print positions wide, with leading and trailing `+`
+🧑‍🏫+

This output should be 3 print positions wide, with leading and trailing `+`
+a+
```
# User-Facing Changes

Users may have to undo fixes they may have introduced to work around the
former behavior. I have one such in my prompt string that I can now
revert.

# Tests + Formatting

Don't forget to add tests that cover your changes.
-- Done

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

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass

# After Submitting

`fill` command not documented in the book, and it still talks about `str
lpad/rpad`. I'll fix.

Note added dependency on a new library `print-positions`, which is an
iterator that yields a complete print position (cluster + Ansi sequence)
per call. Should this be vendored?
2023-02-20 06:32:20 -06:00
dependabot[bot]
527c44ed84
Bump sysinfo from 0.27.7 to 0.28.0 (#8132)
Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.27.7
to 0.28.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md">sysinfo's
changelog</a>.</em></p>
<blockquote>
<h1>0.28.0</h1>
<ul>
<li>Linux: Fix name and CPU usage for processes tasks.</li>
<li>unix: Keep all users, even &quot;not real&quot; accounts.</li>
<li>Windows: Use SID for Users ID.</li>
<li>Fix C API.</li>
<li>Disable default cdylib compilation.</li>
<li>Add <code>serde</code> feature to enable serialization.</li>
<li>Linux: Handle <code>Idle</code> state in
<code>ProcessStatus</code>.</li>
<li>Linux: Add brand and name of ARM CPUs.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/GuillaumeGomez/sysinfo/commits">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=sysinfo&package-manager=cargo&previous-version=0.27.7&new-version=0.28.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 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>
2023-02-19 20:58:07 -06:00
dependabot[bot]
8ee015a847
Bump winreg from 0.10.1 to 0.11.0 (#8128)
Bumps [winreg](https://github.com/gentoo90/winreg-rs) from 0.10.1 to
0.11.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/gentoo90/winreg-rs/blob/master/CHANGELOG.md">winreg's
changelog</a>.</em></p>
<blockquote>
<h2>0.11.0</h2>
<ul>
<li>Migrate to the 2018 edition of Rust</li>
<li>Move the code from <code>lib.rs</code> to separate files</li>
<li>Use <a
href="https://crates.io/crates/cfg-if"><code>cfg-if</code></a> instead
of <code>build.rs</code> to fail build on non-windows systems</li>
<li>Reimplement deserialization logic, implement [de]serialization for
byte arrays (<a
href="https://github-redirect.dependabot.com/gentoo90/winreg-rs/issues/49">#49</a>)</li>
<li>Fix some typos and <code>clippy</code> warnings</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="f34742d674"><code>f34742d</code></a>
Bump version to 0.11.0</li>
<li><a
href="75f2593f62"><code>75f2593</code></a>
Move the changelog to a separate file</li>
<li><a
href="1f6f877ed7"><code>1f6f877</code></a>
Fix some clippy warnings</li>
<li><a
href="7a32d642cd"><code>7a32d64</code></a>
Implement [de]serialization for byte arrays</li>
<li><a
href="8464557c2d"><code>8464557</code></a>
Reimplement deserialization logic</li>
<li><a
href="9e8dc28029"><code>9e8dc28</code></a>
Put serialization tests into a separate file</li>
<li><a
href="04f7d232c7"><code>04f7d23</code></a>
Use <code>cfg-if</code> to fail build on non-windows systems</li>
<li><a
href="c3ac5ba5ea"><code>c3ac5ba</code></a>
Move the code from <code>lib.rs</code> to separate files</li>
<li><a
href="17378a9ca4"><code>17378a9</code></a>
Migrate to the 2018 edition of Rust</li>
<li><a
href="f4d45923ab"><code>f4d4592</code></a>
Remove Appveyor. It's broken anyway</li>
<li>Additional commits viewable in <a
href="https://github.com/gentoo90/winreg-rs/compare/v0.10.1...v0.11.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=winreg&package-manager=cargo&previous-version=0.10.1&new-version=0.11.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 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>
2023-02-19 20:57:46 -06:00
Antoine Stevan
88e07b5ea4
DOCUMENTATION: add a new "key-value" example to with-env (#8119)
hello there 👋 😋 

when messing around with `with-env`, looking at the examples, i did not
understand that we could directly run `with-env` with a record as the
argument and not from the input of a pipe 😮

even though the last example, i.e. 
```bash
  Set by row(e.g. `open x.json` or `from json`)
  > '{"X":"Y","W":"Z"}'|from json|with-env $in { [$env.X $env.W] }
```
, is equivalent, just the record comes from the pipe, i thought adding
that explicite new example could be helpful 😌
 
# Description
looking at the single real change of this PR, i.e. 86ef34e90, you can
see i've simply added
```bash
  Set by key-value record
  > with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
```
just before the example above

> **Note**
> i've also added spaces around the '|' in the last examples, from
> ```bash
>   > '{"X":"Y","W":"Z"}'|from json|with-env $in { [$env.X $env.W] }
> ```
> to
> ```bash
>   > '{"X":"Y","W":"Z"}' | from json | with-env $in { [$env.X $env.W] }
> ```
> hopefully making the pipeline a bit easier to read 👍

### hope you like that 😏 

# User-Facing Changes
a new example has been added to `with-env`

# Tests + Formatting
no tests have been added

# After Submitting
the change should not affect the website, i think

=> if i need to generate the associated `HTML` file on
https://github.com/nushell/nushell.github.io, please tell me 😋
2023-02-19 18:28:49 +00:00
Jakub Žádník
f3ee8b50e3
Revert #7779 (enables back subcommand completions) (#8102)
# Description

Reverts the PR #7779 which breaks subcommand completions. The issues
#7648 and #7754 thus still need fixing.

This reverts commit 8acced5.

# User-Facing Changes

Enables subcommand completions.

Unfortunately, also brings back the completion panic if alias is shorter
than the command name.

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-18 17:38:29 +00:00
WindSoilder
789b2e603a
update nu_plugin_python due to signature changes (#8107)
# Description

As title..

# User-Facing Changes

None

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-18 13:27:24 +00:00
Jérémy Audiger
66398fbf77
Factorize HTTP commands code (#8088)
# Description

In order to work on https://github.com/nushell/nushell/issues/2741, I'm
preparing the code.

# User-Facing Changes

Both commands do support the timeout option.

**But the timeout argument `-t, --timeout` has been migrated to `-m,
--max-time`**. I had to make a choice since there is another option
using the short command `t` which is "content-type".

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-17 23:10:29 +00:00
Maxim Zhiburt
daeb3e5187
nu-table/ table --collapse style fix (#8041)
close #8033

So as I said they suppose to be there;

I've basically added a change of style if --collapse is used.

PS: I guess it's worth to add tests so hold on if you'll plan to merge
it.

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-16 19:32:07 +00:00
David Matos
1fd1a3a456
Support URLs in start command (#7799)
# Description
Fixes issue #7792 Fix basically by @kubouch , "stolen" by me :). Edit:
Added "proper" fix rather than the one liner
```
start Cargo.toml
// Opens in default editor 
```

```
start https://www.google.com [alternative_browser]
// Opens page in default browser or another browser if specified
```

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

- [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 -A
clippy::needless_collect` to check that you're using the standard code
style
- [X] `cargo test --workspace` to check that all tests pass

# 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.
2023-02-16 13:33:25 +00:00
Darren Schroeder
30ac2d220c
update colors in dark theme (#8090)
# Description

I noticed a bug in the default_config.nu while debugging something else.
The colors in the dark_theme should be named colors and not rgb colors.
Rgb colors prevents the dark theme from working properly in terminals
that don't support 24-bit aka rgb colors.

# User-Facing 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-16 06:59:26 -06:00
JT
ade7bde813
Bare word improvements (#8066)
# Description

This does two fixes for bare words:

* It changes completions for paths to wrap a path with backticks if it
starts with a number. This helps bare words that start with numbers be
separate from unit values
* It allows bare words wrapped with backticks to be the name of a
command. Backtick values in command positions are no longer treated as
strings

# 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 -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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.
2023-02-16 02:30:56 +00:00