Commit Graph

4056 Commits

Author SHA1 Message Date
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