Compare commits

...

96 Commits

Author SHA1 Message Date
bc38a6a795 Bump version for 0.76.0 release (#8121)
Before landing:

- [x] `reedline 0.16.0` is out and pinned.
- [x] all fixes and features necessary are landed.

In the meantime:

- [ ] feed the release notes with relevant features and breaking changes
2023-02-21 20:46:29 +00:00
e89866bedb TEST: add the output to the new with-env example (#8148)
Related to #8119.
Should address the review comment by @sholderbach from #8119.


# Description

this PR adds the output to the new example for the `with-env` command
introduced by #8119.

```bash
with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
```
should output
```bash
["Y", "Z"]
```
hence the proposition from @sholderbach, i.e.
```rust
Some(Value::list(
    vec![Value::test_string("Y"), Value::test_string("Z")],
    Span::test_data(),
))
```

# User-Facing Changes
_none_

# Tests + Formatting

not really a test, only the output value for the last `with-env` example

- ✔️ `cargo fmt --all`
- ✔️ `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- ✔️ `cargo test --workspace`

# After Submitting
_none_
2023-02-21 10:15:35 +00:00
ca09dbbbee Pin reedline to 0.16.0 (#8142)
# Description

See release notes:
https://github.com/nushell/reedline/releases/tag/v0.16.0

# User-Facing Changes

Only internal

# Tests + Formatting

(-)
2023-02-20 21:44:04 +00:00
fa4531fd17 Bump actions-rust-lang/setup-rust-toolchain from 1.3.7 to 1.4.2 (#8133)
Bumps
[actions-rust-lang/setup-rust-toolchain](https://github.com/actions-rust-lang/setup-rust-toolchain)
from 1.3.7 to 1.4.2.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/CHANGELOG.md">actions-rust-lang/setup-rust-toolchain's
changelog</a>.</em></p>
<blockquote>
<h2>[1.4.2] - 2023-02-15</h2>
<h3>Fixed</h3>
<ul>
<li>Tweak sparse registry version regex to better work with 1.68 nightly
versions.</li>
<li>Fix command not found issue</li>
</ul>
<h2>[1.4.1] - 2023-02-13</h2>
<h3>Fixed</h3>
<ul>
<li>
<p>Fixed running on macOS <a
href="https://github-redirect.dependabot.com/actions-rust-lang/setup-rust-toolchain/issues/9">#9</a>
<a
href="https://github-redirect.dependabot.com/actions-rust-lang/setup-rust-toolchain/issues/10">#10</a>
The macOS images have an ancient version of bash, but the action relies
on &quot;newer&quot; features than 2014.
We install bash via brew (already pre-installed) to have a new enough
version.</p>
<p>The CI is extended to also run on Windows and macOS to catch such
issues earlier in the future.</p>
<p>Thanks to <a
href="https://github.com/GeorgeHahn"><code>@​GeorgeHahn</code></a> for
reporting the issue.</p>
</li>
</ul>
<h2>[1.4.0] - 2023-02-13</h2>
<h3>Changed</h3>
<ul>
<li>Only set environment variables, if they are not set before.
This allows setting environment variables before using this action and
keeping their values.</li>
<li>Enable stable sparse registry, except on versions 1.66 and 1.67
where this leads to errors.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="9fa7c33ef0"><code>9fa7c33</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/actions-rust-lang/setup-rust-toolchain/issues/11">#11</a>
from actions-rust-lang/tweak-regex</li>
<li><a
href="5f4f30a995"><code>5f4f30a</code></a>
Maybe fix rustup warning</li>
<li><a
href="2d7b97c05c"><code>2d7b97c</code></a>
Tweak sparse registry version regex and command not found</li>
<li><a
href="c7c759a5c9"><code>c7c759a</code></a>
New version with macOS fix</li>
<li><a
href="ba68a52e42"><code>ba68a52</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/actions-rust-lang/setup-rust-toolchain/issues/10">#10</a>
from actions-rust-lang/issue-9</li>
<li><a
href="40e33d4912"><code>40e33d4</code></a>
Install newer bash on macOS</li>
<li><a
href="8ba1b441e5"><code>8ba1b44</code></a>
Run CI on more platforms</li>
<li><a
href="51b4f8316a"><code>51b4f83</code></a>
Bump version to 1.4.0</li>
<li><a
href="4605df10a0"><code>4605df1</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/actions-rust-lang/setup-rust-toolchain/issues/8">#8</a>
from actions-rust-lang/sparse-registry</li>
<li><a
href="eac5ebb2ae"><code>eac5ebb</code></a>
Fix: Use acceptable crate name (lowercase)</li>
<li>Additional commits viewable in <a
href="https://github.com/actions-rust-lang/setup-rust-toolchain/compare/v1.3.7...v1.4.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions-rust-lang/setup-rust-toolchain&package-manager=github_actions&previous-version=1.3.7&new-version=1.4.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-02-20 19:22:52 +00:00
d17c970f8c update code coversage script to work better with windows (#8141)
# Description

This PR updates the code coverage script to help it work better on
Windows. The main changes here are to give you some progress outputs and
to enable `cargo llvm-cov show-env | from toml` to work better since the
toml spec says these literal strings should be single quoted vs double
quoted.

Closed #8139

# 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-20 19:21:41 +00:00
6ca62ef131 show more informaiton when there are toml errors (#8140)
# Description

While debugging #8139 I noticed that there was some error information
coming from the toml crate that we were not displaying. This would've
helped me to understand what was going on. So, this PR shows more
verbose errors when toml fails to parse.

### Before

```
cargo llvm-cov show-env | from toml 
Error: nu:🐚:cant_convert (link)

  × Can't convert to structured toml data.
   ╭─[entry #1:1:1]
 1 │ cargo llvm-cov show-env | from toml
   · ──┬──
   ·   ╰── can't convert string to structured toml data
   ╰────
```

### After

```
cargo llvm-cov show-env | from toml
Error: nu:🐚:cant_convert (link)

  × Can't convert to structured toml data.
   ╭─[entry #1:1:1]
 1 │ cargo llvm-cov show-env | from toml
   · ──┬──
   ·   ╰── can't convert string to structured toml data
   ╰────
  help: TOML parse error at line 2, column 24
          |
        2 | LLVM_PROFILE_FILE="C:\CarTar\nushell-%p-%m.profraw"
          |                        ^
        invalid escape sequence
        expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`
```

# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-20 18:50:31 +00:00
8e84e33638 add usage for plugin commands (#8138)
# Description

As title

# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-20 15:03:17 +00:00
b9be416937 Add colors in table --collapse (#8120)
close #8110 

cc: @amtoine

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-20 12:59:33 +00:00
0a8c9b22b0 string | fill counts clusters, not graphemes; and doesn't count ANSI escape codes (#8134)
Enhancement of new `fill` command (#7846) to handle content including
ANSI escape codes for formatting or multi-code-point Unicode grapheme
clusters.
In both of these cases, the content is (many) bytes longer than its
visible length, and `fill` was counting the extra bytes so not adding
enough fill characters.

# Description

This script:
```rust
# the teacher emoji `\u{1F9D1}\u{200D}\u{1F3EB}` is 3 code points, but only 1 print position wide.
echo "This output should be 3 print positions wide, with leading and trailing `+`"
$"\u{1F9D1}\u{200D}\u{1F3EB}" | fill -c "+" -w 3 -a "c"

echo "This output should be 3 print positions wide, with leading and trailing `+`"
$"(ansi green)a(ansi reset)" | fill -c "+" -w 3 -a c
echo ""
```

Was producing this output:
```rust
This output should be 3 print positions wide, with leading and trailing `+`
🧑‍🏫

This output should be 3 print positions wide, with leading and trailing `+`
a
```

After this PR, it produces this output:
```rust
This output should be 3 print positions wide, with leading and trailing `+`
+🧑‍🏫+

This output should be 3 print positions wide, with leading and trailing `+`
+a+
```
# User-Facing Changes

Users may have to undo fixes they may have introduced to work around the
former behavior. I have one such in my prompt string that I can now
revert.

# Tests + Formatting

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

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

- [x] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- [x] `cargo test --workspace` to check that all tests pass

# After Submitting

`fill` command not documented in the book, and it still talks about `str
lpad/rpad`. I'll fix.

Note added dependency on a new library `print-positions`, which is an
iterator that yields a complete print position (cluster + Ansi sequence)
per call. Should this be vendored?
2023-02-20 06:32:20 -06:00
527c44ed84 Bump sysinfo from 0.27.7 to 0.28.0 (#8132)
Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.27.7
to 0.28.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md">sysinfo's
changelog</a>.</em></p>
<blockquote>
<h1>0.28.0</h1>
<ul>
<li>Linux: Fix name and CPU usage for processes tasks.</li>
<li>unix: Keep all users, even &quot;not real&quot; accounts.</li>
<li>Windows: Use SID for Users ID.</li>
<li>Fix C API.</li>
<li>Disable default cdylib compilation.</li>
<li>Add <code>serde</code> feature to enable serialization.</li>
<li>Linux: Handle <code>Idle</code> state in
<code>ProcessStatus</code>.</li>
<li>Linux: Add brand and name of ARM CPUs.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/GuillaumeGomez/sysinfo/commits">compare
view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-19 20:58:07 -06:00
8ee015a847 Bump winreg from 0.10.1 to 0.11.0 (#8128)
Bumps [winreg](https://github.com/gentoo90/winreg-rs) from 0.10.1 to
0.11.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/gentoo90/winreg-rs/blob/master/CHANGELOG.md">winreg's
changelog</a>.</em></p>
<blockquote>
<h2>0.11.0</h2>
<ul>
<li>Migrate to the 2018 edition of Rust</li>
<li>Move the code from <code>lib.rs</code> to separate files</li>
<li>Use <a
href="https://crates.io/crates/cfg-if"><code>cfg-if</code></a> instead
of <code>build.rs</code> to fail build on non-windows systems</li>
<li>Reimplement deserialization logic, implement [de]serialization for
byte arrays (<a
href="https://github-redirect.dependabot.com/gentoo90/winreg-rs/issues/49">#49</a>)</li>
<li>Fix some typos and <code>clippy</code> warnings</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="f34742d674"><code>f34742d</code></a>
Bump version to 0.11.0</li>
<li><a
href="75f2593f62"><code>75f2593</code></a>
Move the changelog to a separate file</li>
<li><a
href="1f6f877ed7"><code>1f6f877</code></a>
Fix some clippy warnings</li>
<li><a
href="7a32d642cd"><code>7a32d64</code></a>
Implement [de]serialization for byte arrays</li>
<li><a
href="8464557c2d"><code>8464557</code></a>
Reimplement deserialization logic</li>
<li><a
href="9e8dc28029"><code>9e8dc28</code></a>
Put serialization tests into a separate file</li>
<li><a
href="04f7d232c7"><code>04f7d23</code></a>
Use <code>cfg-if</code> to fail build on non-windows systems</li>
<li><a
href="c3ac5ba5ea"><code>c3ac5ba</code></a>
Move the code from <code>lib.rs</code> to separate files</li>
<li><a
href="17378a9ca4"><code>17378a9</code></a>
Migrate to the 2018 edition of Rust</li>
<li><a
href="f4d45923ab"><code>f4d4592</code></a>
Remove Appveyor. It's broken anyway</li>
<li>Additional commits viewable in <a
href="https://github.com/gentoo90/winreg-rs/compare/v0.10.1...v0.11.0">compare
view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-19 20:57:46 -06:00
e8cabd16d5 Add a script to generate coverage locally (#8125)
# Description

This can be triggered manually and inspected for example with:

-
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
- https://github.com/umaumax/vim-lcov
- https://github.com/andythigpen/nvim-coverage (probably with some
effort)

Currently I try to use the `--profile=ci` as well as the CI coverage
action relies on it but the flags passed to build and test differ.
First locally I don't run into the out of disk space problems of the CI
runners when also allowing the plugin tests to run. Furthermore I am not
fully sure what is going on with the recompilation between `cargo build`
and `cargo test`. Chose the most simple config, people might use for
running the test suite locally.



# User-Facing Changes

> Developers, Developers, Developers

Steve Ballmer
2023-02-19 21:19:48 +00:00
88e07b5ea4 DOCUMENTATION: add a new "key-value" example to with-env (#8119)
hello there 👋 😋 

when messing around with `with-env`, looking at the examples, i did not
understand that we could directly run `with-env` with a record as the
argument and not from the input of a pipe 😮

even though the last example, i.e. 
```bash
  Set by row(e.g. `open x.json` or `from json`)
  > '{"X":"Y","W":"Z"}'|from json|with-env $in { [$env.X $env.W] }
```
, is equivalent, just the record comes from the pipe, i thought adding
that explicite new example could be helpful 😌
 
# Description
looking at the single real change of this PR, i.e. 86ef34e90, you can
see i've simply added
```bash
  Set by key-value record
  > with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
```
just before the example above

> **Note**
> i've also added spaces around the '|' in the last examples, from
> ```bash
>   > '{"X":"Y","W":"Z"}'|from json|with-env $in { [$env.X $env.W] }
> ```
> to
> ```bash
>   > '{"X":"Y","W":"Z"}' | from json | with-env $in { [$env.X $env.W] }
> ```
> hopefully making the pipeline a bit easier to read 👍

### hope you like that 😏 

# User-Facing Changes
a new example has been added to `with-env`

# Tests + Formatting
no tests have been added

# After Submitting
the change should not affect the website, i think

=> if i need to generate the associated `HTML` file on
https://github.com/nushell/nushell.github.io, please tell me 😋
2023-02-19 18:28:49 +00:00
f3ee8b50e3 Revert #7779 (enables back subcommand completions) (#8102)
# Description

Reverts the PR #7779 which breaks subcommand completions. The issues
#7648 and #7754 thus still need fixing.

This reverts commit 8acced5.

# User-Facing Changes

Enables subcommand completions.

Unfortunately, also brings back the completion panic if alias is shorter
than the command name.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-18 17:38:29 +00:00
68ad854b0d update link to command reference (#8111)
# Description

Broken link

# 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-18 07:38:36 -06:00
789b2e603a update nu_plugin_python due to signature changes (#8107)
# Description

As title..

# User-Facing Changes

None

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-18 13:27:24 +00:00
66398fbf77 Factorize HTTP commands code (#8088)
# Description

In order to work on https://github.com/nushell/nushell/issues/2741, I'm
preparing the code.

# User-Facing Changes

Both commands do support the timeout option.

**But the timeout argument `-t, --timeout` has been migrated to `-m,
--max-time`**. I had to make a choice since there is another option
using the short command `t` which is "content-type".

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-17 23:10:29 +00:00
daeb3e5187 nu-table/ table --collapse style fix (#8041)
close #8033

So as I said they suppose to be there;

I've basically added a change of style if --collapse is used.

PS: I guess it's worth to add tests so hold on if you'll plan to merge
it.

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-16 19:32:07 +00:00
1fd1a3a456 Support URLs in start command (#7799)
# Description
Fixes issue #7792 Fix basically by @kubouch , "stolen" by me :). Edit:
Added "proper" fix rather than the one liner
```
start Cargo.toml
// Opens in default editor 
```

```
start https://www.google.com [alternative_browser]
// Opens page in default browser or another browser if specified
```

# User-Facing Changes

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

# Tests + Formatting

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

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

- [X] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [X] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- [X] `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-16 13:33:25 +00:00
30ac2d220c update colors in dark theme (#8090)
# Description

I noticed a bug in the default_config.nu while debugging something else.
The colors in the dark_theme should be named colors and not rgb colors.
Rgb colors prevents the dark theme from working properly in terminals
that don't support 24-bit aka rgb colors.

# User-Facing Changes


# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-16 06:59:26 -06:00
JT
ade7bde813 Bare word improvements (#8066)
# Description

This does two fixes for bare words:

* It changes completions for paths to wrap a path with backticks if it
starts with a number. This helps bare words that start with numbers be
separate from unit values
* It allows bare words wrapped with backticks to be the name of a
command. Backtick values in command positions are no longer treated as
strings

# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-16 02:30:56 +00:00
cba3e100a0 fix rename when it is passed an empty column list to rename (#8086)
# Description

This PR fixes a bug that occurs if you pass `rename --column` and empty
list like `ls | rename -c []`.

## Before

```
> ls | rename -c []
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', crates\nu-command\src\filters\rename.rs:110:15
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

## After

```
> ls | rename -c []
Error: nu:🐚:type_mismatch (link)

  × Type mismatch.
   ╭─[entry #1:1:1]
 1 │ ls | rename -c []
   ·                ─┬
   ·                 ╰── The list cannot be empty and must contain only two values: the column's name and its replacement value
   ╰────
```

# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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-15 21:47:27 +00:00
664d8d3573 allow date grouping in group-by (#8084)
# Description

This small change allows tables to be grouped by date. It was previously
failing because nushell didn't know how to represent the date as a
string. This change allows the date to be formatted in rfc3339 format
with subseconds represented as dot milliseconds. This formatted datetime
representation is already understood by nushell.

Now you can do things like 

### Grouping by the exact time
```
> ls | group-by modified | table
╭───────────────────────────────┬────────────────╮
│ 2022-01-07T07:53:44.658-06:00 │ [table 1 row]  │
│ 2022-11-29T08:08:09.411-06:00 │ [table 2 rows] │
│ 2023-02-15T08:23:16.044-06:00 │ [table 5 rows] │
│ 2023-01-04T14:45:08.940-06:00 │ [table 2 rows] │
│ 2022-04-08T08:12:50.295-05:00 │ [table 1 row]  │
│ 2022-09-15T10:11:21.177-05:00 │ [table 1 row]  │
│ 2022-06-22T14:26:56.409-05:00 │ [table 1 row]  │
│ 2023-02-08T09:24:32.774-06:00 │ [table 1 row]  │
│ 2022-05-25T11:57:00.866-05:00 │ [table 2 rows] │
│ 2023-02-15T08:23:16.054-06:00 │ [table 4 rows] │
│ 2023-01-04T14:45:08.970-06:00 │ [table 3 rows] │
│ 2022-08-05T07:14:06.265-05:00 │ [table 1 row]  │
│ 2022-01-07T07:53:44.728-06:00 │ [table 1 row]  │
│ 2023-01-27T09:39:34.351-06:00 │ [table 1 row]  │
│ 2023-02-08T09:24:32.794-06:00 │ [table 1 row]  │
│ 2023-02-15T08:36:26.524-06:00 │ [table 1 row]  │
│ 2023-01-19T12:53:22.033-06:00 │ [table 1 row]  │
╰───────────────────────────────┴────────────────╯
```
### Grouping by only the date (truncating the time componenet to 0)
```
> ls | default "" date | update date {|r| $r.modified | date format '%Y-%m-%d' | into datetime} | group-by date | table
╭───────────────────────────────┬─────────────────╮
│ 2022-01-07T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2022-11-29T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2023-02-15T00:00:00.000-06:00 │ [table 10 rows] │
│ 2023-01-04T00:00:00.000-06:00 │ [table 5 rows]  │
│ 2022-04-08T00:00:00.000-06:00 │ [table 1 row]   │
│ 2022-09-15T00:00:00.000-06:00 │ [table 1 row]   │
│ 2022-06-22T00:00:00.000-06:00 │ [table 1 row]   │
│ 2023-02-08T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2022-05-25T00:00:00.000-06:00 │ [table 2 rows]  │
│ 2022-08-05T00:00:00.000-06:00 │ [table 1 row]   │
│ 2023-01-27T00:00:00.000-06:00 │ [table 1 row]   │
│ 2023-01-19T00:00:00.000-06:00 │ [table 1 row]   │
╰───────────────────────────────┴─────────────────╯
```
### Grouping and Displaying only the date (you could do this before this
PR too)
```
> ls | default "" date | update date {|r| $r.modified | date format '%Y-%m-%d'} | group-by date | table
╭────────────┬─────────────────╮
│ 2022-01-07 │ [table 2 rows]  │
│ 2022-11-29 │ [table 2 rows]  │
│ 2023-02-15 │ [table 10 rows] │
│ 2023-01-04 │ [table 5 rows]  │
│ 2022-04-08 │ [table 1 row]   │
│ 2022-09-15 │ [table 1 row]   │
│ 2022-06-22 │ [table 1 row]   │
│ 2023-02-08 │ [table 2 rows]  │
│ 2022-05-25 │ [table 2 rows]  │
│ 2022-08-05 │ [table 1 row]   │
│ 2023-01-27 │ [table 1 row]   │
│ 2023-01-19 │ [table 1 row]   │
╰────────────┴─────────────────╯
```
### Shows that nushell understands the rfc3339 format
```
> 2022-01-07T07:53:44.658-06:00 | describe 
date
> 2022-01-07T07:53:44.658-06:00 | date format '%Y-%m-%d'
2022-01-07
```
# User-Facing Changes

Related to #8036

# 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-15 19:10:55 +00:00
d5ce509e3a move ast command to the debug group (#8077)
# Description

This PR tweaks how `ast` works a tiny bit by outputting values in stead
of eprintln!'s. It also moves the `ast` command into the folder with the
rest of the debug commands and changes the category to debug.

I started adding some tests but couldn't figure out a good way to do it
since every `ast` command contains spans that will be different on each
invocation.

# 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-14 18:47:34 +00:00
2f10d19c98 remove spurious use from default_context.rs (#8073)
For some reason this "Use" in default_context.rs was in the code,
but it is not being "used" --- pun intended...
2023-02-13 20:14:20 +00:00
4c787af26d relocate debug commands (#8071)
# Description

Now that we've landed the debug commands we were working on, let's
relocate them to an easier place to find all of them. That's what this
PR does.

The only actual code change was changing the `timeit` command to a
`Category::Debug` command. The rest is just moving things around and
hooking them up.

# 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-13 16:39:07 +00:00
8136170431 support multiplication operation on string and list values (#8061)
# Description

As title, I found this feature is useful to me too :)

Closes: #8039

# User-Facing Changes

```
❯ 3 * "ab"
ababab

❯ 3 * [1 2 3]
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │ 3 │
│ 3 │ 1 │
│ 4 │ 2 │
│ 5 │ 3 │
│ 6 │ 1 │
│ 7 │ 2 │
│ 8 │ 3 │
╰───┴───╯
```

# 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-13 16:35:53 +00:00
007916c2c1 Syntax errors for string and int (#7952)
# Description

Added a few syntax errors in ints and strings, changed parser to stop
and show that error rather than continue trying to parse those tokens as
some other shape. However, I don't see how to push this direction much
further, and most of the classic confusing errors can't be changed.

Flagged as WIP for the moment, but passes all checks and works better
than current release:
1. I have yet to figure out how to make these errors refer back to the
book, as I see some other errors do.
2. How to give syntax error when malformed int is first token in line?
Currently parsed as external command, user gets confusing error message.
3. Would like to be more strict with *decimal* int literals (lacking,
e.g, `0x' prefix). Need to tinker more with the order of parse shape
calls, currently, float is tried after int, so '1.4' has to be passed.

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

```bash

〉"\z"
Error: 
   ╭─[entry #3:1:1]
 1 │ "\z"
   ·  ─┬─
   ·   ╰── Syntax error in string, unrecognized character after escape '\'.
   ╰────
```
Canonic presentation of a syntax error.
```bash
〉"  \u{01ffbogus}"
Error: 
  × Invalid syntax
   ╭─[entry #2:1:1]
 1 │ "  \u{01ffbogus}"
   ·    ───────┬──────
   ·           ╰── Syntax error in string, expecting 1 to 6 hex digits in unicode escape '\u{X...}', max value 10FFFF.
   ╰────
```
Malformed unicode escape in string, flagged as error.  
String parse can be opinionated, it's the last shape tried.
```bash
〉0x22bogus
Error: nu:🐚:external_command (link)
  × External command failed
   ╭─[entry #4:1:1]
1 │ 0x22bogus
   · ────┬────
   ·     ╰── executable was not found
   ╰────
  help: No such file or directory (os error 2)
```
A *correct* number in first token would be evaluated, but an *incorrect*
one is treated as external command? Confusing to users.
```bash
〉0 + 0x22bogus
Error: 
  × Invalid syntax
   ╭─[entry #5:1:1]
1 │ 0 + 0x22bogus
   ·     ────┬────
   ·         ╰── Syntax error in int, invalid digits in radix 16 int.
   ╰────
```
Can give syntax error if token is unambiguously int literal. e.g has 0b
or 0x prefix, could not be a float.
```bash
〉0 + 098bogus
Error: nu::parser::unsupported_operation (link)

  × Types mismatched for operation.
   ╭─[entry #6:1:1]
 1 │ 0 + 098bogus
   · ┬ ┬ ────┬───
   · │ │     ╰── string
   · │ ╰── doesn't support these values.
   · ╰── int
   ╰────
  help: Change int or string to be the right types and try again.
```
But *decimal* literal (no prefix) can't be too strict. Parser is going
to try float later. So '1.4' must be passed.

# User-Facing Changes

First and foremost, more specific error messages for typos in string and
int literals. Probably improves interactive user experience.

But a script that was causing and then checking for specific error might
notice a different error message.

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

# Tests + Formatting

Added (positive and negative unit tests in `cargo test -p nu-parser`.
Didn't add integration tests.

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: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-02-13 16:09:50 +00:00
208ffdc1da Move some from xxx commands to plugin (#7942)
# Description

From nushell 0.8 philosophy:
https://github.com/nushell/nushell.github.io/blob/main/contributor-book/philosophy_0_80.md#core-categories

> The following categories should be moved to plugins:
Uncommon format support

So this pr is trying to move following commands to plugin:
- [X] from eml
- [x] from ics
- [x] from ini
- [x] from vcf

And we can have a new plugin handles for these formatting, currently
it's implemented here:

https://github.com/WindSoilder/nu_plugin_format

The command usage should be the same to original command.

If it's ok, the plugin can support more formats like
[parquet](https://github.com/fdncred/nu_plugin_from_parquet), or [EDN
format](https://github.com/nushell/nushell/issues/6415), or something
else.

Just create a draft pr to show what's the blueprint looks like, and is
it a good direction to move forward?

# 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-13 12:42:08 +00:00
4468dc835c Make patch coverage check informational only (#8069)
See:
https://docs.codecov.com/docs/common-recipe-list#set-non-blocking-status-checks
2023-02-13 10:30:24 +00:00
90a2352337 Bump roxmltree from 0.17.0 to 0.18.0 (#8065)
Bumps [roxmltree](https://github.com/RazrFalcon/roxmltree) from 0.17.0
to 0.18.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/RazrFalcon/roxmltree/blob/master/CHANGELOG.md">roxmltree's
changelog</a>.</em></p>
<blockquote>
<h2>[0.18.0] - 2023-02-04</h2>
<h3>Added</h3>
<ul>
<li><code>StringStorage</code> that exposes an internal string
storage.</li>
<li>Allocated strings are stored as <code>Arc&lt;str&gt;</code> and not
<code>String</code> now.</li>
<li><code>Node::text_storage</code></li>
<li><code>Node::tail_storage</code></li>
<li><code>Attribute::value_storage</code></li>
<li><code>Node::range</code></li>
</ul>
<h3>Removed</h3>
<ul>
<li><code>Node::position</code>. Use <code>Node::range</code>
instead.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Some methods return longer lifetimes now.
Thanks to <a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a></li>
<li>Overly verbose Debug implementations.
Thanks to <a
href="https://github.com/adamreichold"><code>@​adamreichold</code></a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8f6f14bbc7"><code>8f6f14b</code></a>
Version bump.</li>
<li><a
href="c4d622fccc"><code>c4d622f</code></a>
Store node's end position again.</li>
<li><a
href="3d33827a75"><code>3d33827</code></a>
Use ref-counted owned strings.</li>
<li><a
href="e81718610a"><code>e817186</code></a>
Expose 'input lifetime where it is the backing lifetime.</li>
<li><a
href="0b12673528"><code>0b12673</code></a>
Use consistent debug impls for the various iterators that avoid
formatting th...</li>
<li>See full diff in <a
href="https://github.com/RazrFalcon/roxmltree/compare/v0.17.0...v0.18.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=roxmltree&package-manager=cargo&previous-version=0.17.0&new-version=0.18.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-13 02:35:09 +00:00
0a9d14fcb3 Bump rstest from 0.15.0 to 0.16.0 (#8064)
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps [rstest](https://github.com/la10736/rstest) from 0.15.0 to 0.16.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/la10736/rstest/releases">rstest's
releases</a>.</em></p>
<blockquote>
<h2>0.16.0</h2>
<p>Use values expression to define test names.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/la10736/rstest/blob/master/CHANGELOG.md">rstest's
changelog</a>.</em></p>
<blockquote>
<h2>[0.16.0] 2022/11/27</h2>
<h3>Changed</h3>
<ul>
<li>Show <code>TEST START</code> banner only when trace some argument:
See <a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/158">#158</a>
for details.</li>
<li>Add values to test name: See <a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/160">#160</a>
for details.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Updated test fixtures to 1.64.0 compiler's error messages.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="d7ff088126"><code>d7ff088</code></a>
Update checkout list</li>
<li><a
href="4386575950"><code>4386575</code></a>
Version 0.16.0 chengelog</li>
<li><a
href="41749a881e"><code>41749a8</code></a>
Fix clippy warning</li>
<li><a
href="daaddde1a0"><code>daaddde</code></a>
Bump to 0.16.0 version and upgrade dependency</li>
<li><a
href="576768e4b3"><code>576768e</code></a>
Fixed dev dependency in rstest_macros</li>
<li><a
href="a6eb3a96cb"><code>a6eb3a9</code></a>
Update rstest_test version</li>
<li><a
href="4a18dd0bd1"><code>4a18dd0</code></a>
Update version</li>
<li><a
href="29648832ce"><code>2964883</code></a>
Update dependency version</li>
<li><a
href="5ad7e3fd61"><code>5ad7e3f</code></a>
<a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/160">#160</a>
Add test for module annotation</li>
<li><a
href="a302be019f"><code>a302be0</code></a>
<a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/160">#160</a>
Tests fixed and add unit for allow</li>
<li>Additional commits viewable in <a
href="https://github.com/la10736/rstest/compare/0.15.0...0.16.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=rstest&package-manager=cargo&previous-version=0.15.0&new-version=0.16.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-13 02:34:09 +00:00
7863fb1087 Bump proptest from 1.0.0 to 1.1.0 (#8063)
Bumps [proptest](https://github.com/proptest-rs/proptest) from 1.0.0 to
1.1.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="75c749ee50"><code>75c749e</code></a>
bump version to 1.1.0</li>
<li><a
href="a7c75a1bcb"><code>a7c75a1</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/proptest-rs/proptest/issues/295">#295</a>
from proptest-rs/replays-dont-count-cases</li>
<li><a
href="a854d2ed7a"><code>a854d2e</code></a>
[replays-dont-count-cases] persisted failures are not counted against
success...</li>
<li><a
href="f8eff50603"><code>f8eff50</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/proptest-rs/proptest/issues/291">#291</a>
from schuelermine/fix/prop_assert_ne!</li>
<li><a
href="d38268304c"><code>d382683</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/proptest-rs/proptest/issues/294">#294</a>
from proptest-rs/fix-ci</li>
<li><a
href="ad0a4d311c"><code>ad0a4d3</code></a>
[fix-ci] changed the line for where the error occurs</li>
<li><a
href="00f29af8e8"><code>00f29af</code></a>
Merge pull request <a
href="https://github-redirect.dependabot.com/proptest-rs/proptest/issues/288">#288</a>
from proptest-rs/const-generic-arbitrary</li>
<li><a
href="a16853f4fc"><code>a16853f</code></a>
Fix prop_assert_ne! requiring import of prop_assert!</li>
<li><a
href="b513a32c72"><code>b513a32</code></a>
Config : support disabling failure persistence via env var (<a
href="https://github-redirect.dependabot.com/proptest-rs/proptest/issues/287">#287</a>)</li>
<li><a
href="7a94e16589"><code>7a94e16</code></a>
note that PROPTEST_CASES and other env var requires the std feature (<a
href="https://github-redirect.dependabot.com/proptest-rs/proptest/issues/262">#262</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/proptest-rs/proptest/compare/1.0.0...v1.1.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=proptest&package-manager=cargo&previous-version=1.0.0&new-version=1.1.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-13 02:31:53 +00:00
072d2a919d #8027 Hide implementation details in invalid cd call (#8049)
# Description

[GH issue](https://github.com/nushell/nushell/issues/8027)

The current error message for a cd command includes a Debug output of
the `io::Error` being returned from `canonicalize_with`, so it's been
replaced with a more user friendly and readable depiction of the error.

# User-Facing Changes

As described in the issue, I've changed the error message for a cd into
a directory that does not exist from:
```
/home/rdevenney/projects/open_source/nushell〉cd asdfasdf                                                                               02/11/2023 08:59:59 PM
Error: nu:🐚:directory_not_found (link)

 × Directory not found
   ╭─[entry #2:1:1]
 1 │ cd asdfasdf
   ·    ────┬───
   ·        ╰── directory not found
   ╰────
  help: IO Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
```
To:
```
/home/rdevenney/projects/open_source/nushell〉cd asdfasdf                                                                               02/11/2023 08:58:38 PM
Error: nu:🐚:directory_not_found (link)

  × Directory not found
   ╭─[entry #1:1:1]
 1 │ cd asdfasdf
   ·    ────┬───
   ·        ╰── directory not found
   ╰────
  help: IO Error: DirectoryNotFound
```
# 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-13 02:24:48 +00:00
ccbdc9f6d8 nu-table/ Fix table --expand issue when table with no header involved (#8045)
close #8029

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-12 23:28:42 +00:00
0f5ea16605 Add a codecov.yml configuration (#8059)
Goal: avoid failing based on small coverage fluctuations.

See:

https://docs.codecov.com/docs/codecovyml-reference
2023-02-12 23:04:18 +00:00
1cd70d7505 Disable auto-benchmark harness for crates (#8057)
# Description

This disables automatic detection of `#[bench]` and other benchmarks
within the crates. Our benchmarks should all live in `benches`

This fixes a problem with criterion flags and should also reduce the
build requirements for `cargo bench` a bit

Taken from https://github.com/nushell/nushell/pull/7952

See:
https://bheisler.github.io/criterion.rs/book/faq.html#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options


# User-Facing Changes

None
2023-02-12 22:22:00 +00:00
b0775b3f1e Fix hidden env vars not being hidden in closures (#8055)
# Description

This one fixes env not being hidden inside closure, reported in the
conversation under https://github.com/nushell/nushell/issues/6593

https://github.com/nushell/nushell/issues/6593
https://github.com/nushell/nushell/issues/7937 still persist. These
seems a bit more involved and might need hidden env tracking also in the
engine state... I'm not yet sure what's causing it.

Also re-enables some env-related tests and removes unused Value clone.

# User-Facing Changes

Just a bugfix

# 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-12 17:48:51 +00:00
2894668b3e Improve error when regex rejects pattern. Resolution of #8037 (#8050)
# Description

Improve error when `str replace <pattern>` detects a problem with
<pattern>.

# User-Facing Changes

New "Incorrect value" error:
```
〉 'C:\Users\kubouch' | str replace 'C:\Users' 'foo'
Error: nu:🐚:incorrect_value (link)

  × Incorrect value.
   ╭─[entry #1:1:1]
 1 │  'C:\Users\kubouch' | str replace 'C:\Users' 'foo'
   ·                                   ─────┬────
   ·                                        ╰── Regex error: Parsing error at position 4: Invalid hex escape
   ╰────
```

We could fruitfully replace some of the current uses of
`ShellError::UnsupportedInput` with this error. 'Incorrect value' is
different from 'wrong type'

# Tests + Formatting

Don't forget to add tests that cover your changes.
* none added / changed.

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-12 13:25:40 +00:00
1096e653b0 update cargo wix to 0.3.4 (#8048)
# Description

hopefully this will make the next winget release go smoother


# 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-12 04:13:28 +00:00
9777d755d5 add benchmark to deprecated commands (#8046)
# Description

This PR adds a deprecated message to the `benchmark` command.
```
> benchmark
Error: nu:🐚:deprecated_command (link)

  × Deprecated command benchmark
   ╭─[entry #1:1:1]
 1 │ benchmark
   · ────┬────
   ·     ╰── 'benchmark' is deprecated. Please use 'timeit' instead.
   ╰────
```

# 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-11 21:39:55 +00:00
58529aa0b2 Benchmark each pipeline element (#7854)
# Description

Adds a `profile` command that profiles each pipeline element of a block
and can also recursively step into child blocks.

# Limitations
* It is implemented using pipeline metadata which currently get lost in
some circumstances (e.g.,
https://github.com/nushell/nushell/issues/4501). This means that the
profiler will lose data coming from subexpressions. This issue will
hopefully be solved in the future.
* It also does not step into individual loop iteration which I'm not
sure why but maybe that's a good thing.

# User-Facing Changes

Shouldn't change any existing behavior.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

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

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-02-11 21:35:48 +00:00
JT
64b6c02a22 Add codecov badge 2023-02-12 08:39:37 +13:00
0780300fb3 add a new inspect command for more debugging (#8028)
# Description

The purpose of this command is to help to debug pipelines. It works by
allowing you to inject the `inspect` command into a pipeline at any
point. Then it shows you what the input description is and what the
input values are that are passed into `inspect`. With each step it
prints this information out while also passing the value information on
to the next step in the pipeline.


![image](https://user-images.githubusercontent.com/343840/218154064-e107859b-d0da-41c6-8e34-2d717639b81c.png)

This command is kind of a "hack job" because it clones maybe too much
and I had to get creative in order to output two different tables. I'm
sure there are many ways this can be improved or combined into other
commands but I wanted to start here. Note that the `inspect` output is
written to stderr and the normal nushell output is written to stdout. If
we were to output both to stdout, nushell would get confused.

# 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-11 18:59:11 +00:00
b9106b633b rename benchmark to time (#8018)
# Description

This PR renames the `benchmark` command to the `time` command.

# User-Facing Changes

new command name

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-11 18:57:48 +00:00
23dfaa2933 Another shot at trying to setup codecov (#7948)
Trying to setup using
https://github.com/taiki-e/cargo-llvm-cov#get-coverage-of-external-tests


https://docs.codecov.com/docs/github-2-getting-a-codecov-account-and-uploading-coverage

Closes #7944
2023-02-11 18:44:35 +00:00
cfd2cc4970 Minor clippy: inline format string (#8043)
# Description

Clippy from nightly being pedantic
2023-02-11 17:47:08 +00:00
710349768f remove the --encoding option from register in the examples (#8038)
# Description
As `register` does not have `--encoding` as an option now, the [*Git
stat plugin for
Nushell*](https://github.com/nushell/nushell/tree/main/crates/nu_plugin_gstat#git-stat-plugin-for-nushell)
is not correct anymore

```
> register ~/.local/share/cargo/bin/nu_plugin_gstat --encoding msgpack
Error: nu::parser::unknown_flag (link)

  × The `register` command doesn't have flag `encoding`.
   ╭─[entry #22:1:1]
 1 │ register ~/.local/share/cargo/bin/nu_plugin_gstat --encoding msgpack
   ·                                                   ─────┬────
   ·                                                        ╰── unknown flag
   ╰────
  help: Available flags: --help(-h), --shell(-s). Use `--help` for more information.
```

This PR then simply removes `--encoding msgpack` from the `register`
call in the documentation of the `gstat` plugin.

# User-Facing Changes
There is no user-facing change in this PR.

# Tests + Formatting
This PR does not change any source code.

# After Submitting
Same here, nothing to report 😉
2023-02-11 13:13:40 +00:00
f4bd78b86d Make metadata a Category::Debug command (#8019)
# Description

This PR changes the `metadata` command to a `Category::Debug` command
for better organization.

# User-Facing Changes

Just a different category.

# 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-10 08:09:21 -06:00
ddb7e4e179 Check ctrl+c when collecting a RawStream (#8020)
I noticed that `open some_big_file | into binary` cannot be cancelled
with `ctrl+c`.

This small PR fixes that by checking `ctrl+c` in
`RawStream::into_bytes()`, and does the same in
`RawStream::into_string()` for good measure.
2023-02-10 20:23:46 +13:00
00601f1835 A fill command to replace str lpad and str rpad (#7846)
# Description

The point of this command is to allow you to be able to format ints,
floats, filesizes, and strings with an alignment, padding, and a fill
character, as strings. It's meant to take the place of `str lpad` and
`str rpad`.

```
> help fill
Fill and Align

Search terms: display, render, format, pad, align

Usage:
  > fill {flags}

Flags:
  -h, --help - Display the help message for this command
  -w, --width <Int> - The width of the output. Defaults to 1
  -a, --alignment <String> - The alignment of the output. Defaults to Left (Left(l), Right(r), Center(c/m), MiddleRight(cr/mr))
  -c, --character <String> - The character to fill with. Defaults to ' ' (space)

Signatures:
  <number> | fill -> <string>
  <string> | fill -> <string>

Examples:
  Fill a string on the left side to a width of 15 with the character '─'
  > 'nushell' | fill -a l -c '─' -w 15

  Fill a string on the right side to a width of 15 with the character '─'
  > 'nushell' | fill -a r -c '─' -w 15

  Fill a string on both sides to a width of 15 with the character '─'
  > 'nushell' | fill -a m -c '─' -w 15

  Fill a number on the left side to a width of 5 with the character '0'
  > 1 | fill --alignment right --character 0 --width 5

  Fill a filesize on the left side to a width of 5 with the character '0'
  > 1kib | fill --alignment middle --character 0 --width 10
```

![image](https://user-images.githubusercontent.com/343840/214133752-6fc93fa7-4003-4eb4-96ed-cd967312e244.png)

# User-Facing Changes

Deprecated `str lpad` and `str rpad`.

# 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-09 14:56:52 -06:00
c31225fdcf explain command (#7957)
# Description

The purpose of this PR is to introduce the `inspect` command. A command
that is used to inspect, but not run, a pipeline to ensure everything
looks right. This is meant as a debugging tool. This is some hackery, so
don't laugh. :)

![image](https://user-images.githubusercontent.com/343840/217896776-99c6bece-172c-4d3d-8cec-dda85d37cada.png)
2023-02-09 13:59:38 -06:00
16b99ed0ba Make ++ operator work with strings and binary values (#8017)
This PR makes `++` (the append operator) work with strings and binary
values. Can now do things like:

```bash
〉"a" ++ "b"
ab
〉0x[01 02] ++ 0x[03]
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   01 02 03                                             •••
```

Closes #8015.
2023-02-10 07:52:10 +13:00
3b6d340603 Bump ical from 0.7.0 to 0.8.0 (#7975)
Bumps [ical](https://github.com/Peltoche/ical-rs) from 0.7.0 to 0.8.0.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/Peltoche/ical-rs/commits">compare view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot 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-10 07:37:51 +13:00
99aea0c71c Filesystem commands print --verbose to stderr (#8014)
# Description

Makes `mkdir`, `cp`, `mv` and `rm` return nothing and print info to
stderr:

![image](https://user-images.githubusercontent.com/17511668/217859228-feffa4bc-c22d-45d3-b330-1903f5a4d938.png)
See https://github.com/nushell/nushell/pull/7925#issuecomment-1420861638
and
[discord](https://discord.com/channels/601130461678272522/615329862395101194/1072523941865857055).

# User-Facing Changes

`mkdir`, `cp`, `mv` and `rm` will return nothing and print info to
stderr with `--verbose` flag.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` 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-09 10:29:34 -08:00
023e244958 view span & view files commands (#7989)
# Description

This PR does the following:
1. Adds a new command called `view span` - which shows what is at the
location of the span parameters
2. Adds a new command called `view` - which just lists all the `view`
commands.
3. Renames `view-source` to `view source`.
4. Adds a new command called `view files` - which shows you what files
are loaded into nushell's EngineState memory.
5. Added a `Category::Debug` and put these commands (and others) into
it. (`inspect` needs to be added to it, but it's not landed yet)

Spans are important to nushell. One of their uses is to show where
errors are. For instance, in this example, the leader lines pointing to
parts of the command line are able to point to `10`, `/`, and `"bob"`
because each of those items have a span.
```
> 10 / "bob"
Error: nu::parser::unsupported_operation (link)

  × Types mismatched for operation.
   ╭─[entry #8:1:1]
 1 │ 10 / "bob"
   · ─┬ ┬ ──┬──
   ·  │ │   ╰── string
   ·  │ ╰── doesn't support these values.
   ·  ╰── int
   ╰────
  help: Change int or string to be the right types and try again.
```


# Examples

## view span
Example:
```
> $env.config | get keybindings | first | debug -r
... bunch of stuff
                    span: Span {
                        start: 68065,
                        end: 68090,
                    },
                },
            ],
            span: Span {
                start: 68050,
                end: 68101,
            },
        },
    ],
    span: Span {
        start: 67927,
        end: 68108,
    },
}
```
To view the last span:
```
> view span 67927 68108 
{
        name: clear_everything
        modifier: control
        keycode: char_l
        mode: emacs
        event: [
            { send: clearscrollback }
        ]
    }
```
> To view the 2nd to last span:
```
view span 68065 68090
{ send: clearscrollback }
```
> To view the 3rd to last span:
```
view span 68050 68101
[
            { send: clearscrollback }
        ]
```

## view files
```
> view files  
╭────┬───────────────────────────────────────────────────────┬────────┬────────┬───────╮
│  # │                       filename                        │ start  │  end   │ size  │
├────┼───────────────────────────────────────────────────────┼────────┼────────┼───────┤
│  0 │ source                                                │      0 │      2 │     2 │
│  1 │ Host Environment Variables                            │      2 │   6034 │  6032 │
│  2 │ C:\Users\a_username\AppData\Roaming\nushell\plugin.nu │   6034 │  31236 │ 25202 │
│  3 │ C:\Users\a_username\AppData\Roaming\nushell\env.nu    │  31236 │  44961 │ 13725 │
│  4 │ C:\Users\a_username\AppData\Roaming\nushell\config.nu │  44961 │  76134 │ 31173 │
│  5 │ defs.nu                                               │  76134 │  91944 │ 15810 │
│  6 │ prompt\oh-my.nu                                       │  91944 │ 111523 │ 19579 │
│  7 │ weather\get-weather.nu                                │ 111523 │ 125556 │ 14033 │
│  8 │ .zoxide.nu                                            │ 125556 │ 127504 │  1948 │
│  9 │ source                                                │ 127504 │ 127561 │    57 │
│ 10 │ entry #1                                              │ 127561 │ 127585 │    24 │
│ 11 │ entry #2                                              │ 127585 │ 127595 │    10 │
╰────┴───────────────────────────────────────────────────────┴────────┴────────┴───────╯
```
`entry #x` will be each command you type in the repl (i think). so, it
may be good to filter those out sometimes.
```
> view files | where filename !~ entry
╭───┬───────────────────────────────────────────────────────┬────────┬────────┬───────╮
│ # │                       filename                        │ start  │  end   │ size  │
├───┼───────────────────────────────────────────────────────┼────────┼────────┼───────┤
│ 0 │ source                                                │      0 │      2 │     2 │
│ 1 │ Host Environment Variables                            │      2 │   6034 │  6032 │
│ 2 │ C:\Users\a_username\AppData\Roaming\nushell\plugin.nu │   6034 │  31236 │ 25202 │
│ 3 │ C:\Users\a_username\AppData\Roaming\nushell\env.nu    │  31236 │  44961 │ 13725 │
│ 4 │ C:\Users\a_username\AppData\Roaming\nushell\config.nu │  44961 │  76134 │ 31173 │
│ 5 │ defs.nu                                               │  76134 │  91944 │ 15810 │
│ 6 │ prompt\oh-my.nu                                       │  91944 │ 111523 │ 19579 │
│ 7 │ weather\get-weather.nu                                │ 111523 │ 125556 │ 14033 │
│ 8 │ .zoxide.nu                                            │ 125556 │ 127504 │  1948 │
│ 9 │ source                                                │ 127504 │ 127561 │    57 │
╰───┴───────────────────────────────────────────────────────┴────────┴────────┴───────╯
```
# User-Facing Changes

I renamed `view-source` to `view source` just to make a group of
commands. No functionality has changed in `view source`.

# 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-09 11:35:23 -06:00
659d890ecf Added fix for #7981 - Replaced crate serde_ini with rust-ini for package nu-command/from (#8009)
# Description

Added fix for #7981 - Replaced crate serde_ini with rust-ini for package
nu-command/from

# Tests + Formatting

Added a test to support addition of the rust-ini crate.

`cargo test --package nu-command --lib -- formats::from::ini::tests
--nocapture`

Executed all tests.

`cargo test --workspace`

---------

Co-authored-by: Nitin Londhe <nitin.londhe@genmills.com>
2023-02-09 12:47:45 +01:00
8e9ed14b89 allow parse to work better with streams (#7870)
# Description

Fixes #7864. Haven't removed redundant code yet; and there's also a
weird visual bug, but I'm not sure if that's the fault of this PR or
just a quirk of how tabling works:

```
/home/gabriel/CodingProjects/nushell〉ping 1.1.1.1 | parse -r '(?P<num>\d+) ttl'                                                                                        01/27/2023 11:28:31 AM
╭───┬─────╮
│ # │ num │
├───┼─────┤
│ 0 │ 1   │
│ 1 │ 2   │
╰───┴─────╯
╭───┬─────╮
│ # │ num │
├───┼─────┤
│ 2 │ 3   │
╰───┴─────╯
╭───┬─────╮
│ # │ num │
├───┼─────┤
│ 3 │ 4   │
│ 4 │ 5   │
╰───┴─────╯
╭───┬─────╮
│ # │ num │
├───┼─────┤
│ 5 │ 6   │
│ 6 │ 7   │
╰───┴─────╯
^C
/home/gabriel/CodingProjects/nushell〉                                                                                                                                  01/27/2023 11:28:59 AM

```

# 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-08 20:59:02 -06:00
f4bf7316fe fix completions PATH vs Path (#8003)
# Description

This PR attempts to fix the completions issue where, on Windows,
completions wouldn't get generated from items in your path environment
variable. This seemed to be down to `PATH` vs `Path`. So, I tried to add
a new function that we can use anywhere to avoid this problem.

# 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-08 20:53:46 -06:00
0527f9bf0d Bump openssl-src from 111.22.0+1.1.1q to 111.25.0+1.1.1t (#8011)
Bumps [openssl-src](https://github.com/alexcrichton/openssl-src-rs) from
111.22.0+1.1.1q to 111.25.0+1.1.1t.
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/alexcrichton/openssl-src-rs/commits">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=openssl-src&package-manager=cargo&previous-version=111.22.0+1.1.1q&new-version=111.25.0+1.1.1t)](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)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/nushell/nushell/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-09 00:23:40 +01:00
055edd886d Make plugin commands support examples. (#7984)
# Description

As title, we can't provide examples for plugin commands, this pr would
make it possible


# User-Facing Changes

Take plugin `nu-example-1` as example:
```
❯ nu-example-1 -h
PluginSignature test 1 for plugin. Returns Value::Nothing

Usage:
  > nu-example-1 {flags} <a> <b> (opt) ...(rest)

Flags:
  -h, --help - Display the help message for this command
  -f, --flag - a flag for the signature
  -n, --named <String> - named string

Parameters:
  a <int>: required integer value
  b <string>: required string value
  (optional) opt <int>: Optional number
  ...rest <string>: rest value string

Examples:
  running example with an int value and string value
  > nu-example-1 3 bb
```

The examples session is newly added.

## Basic idea behind these changes
when nushell query plugin signatures, plugin just returns it's signature
without any examples, so nushell have no idea about the examples of
plugin commands.
To adding the feature, we just making plugin returns it's signature with
examples.

Before:
```
        1. get signature
         ----------------> 
Nushell ------------------  Plugin
        <-----------------
        2. returns Vec<Signature>
```

After:
```
        1. get signature
        ----------------> 
Nushell ------------------  Plugin
        <-----------------
        2. returns Vec<PluginSignature>
```
        
When writing plugin signature to $nu.plugin-path:
Serialize `<PluginSignature>` rather than `<Signature>`, which would
enable us to serialize examples to `$nu.plugin-path`

## Shortcoming
It's a breaking changes because `Plugin::signature` is changed, and it
requires plugin authors to change their code for new signatures.

Fortunally it should be easy to change, for rust based plugin, we just
need to make a global replace from word `Signature` to word
`PluginSignature` in their plugin project.

Our content of plugin-path is really large, if one plugin have many
examples, it'd results to larger body of $nu.plugin-path, which is not
really scale. A solution would be save register information in other
binary formats rather than `json`. But I think it'd be another story.

# 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-08 16:14:18 -06:00
5e70d4121a Add dfr to dataframe cmds (#7998)
# Description

This PR tries to resolve the overloading issue by going back to our
original naming convention for dataframes. So, this PR renames all
dataframe commands with a prefix of `dfr`. Some commands like `open-df`
were renamed to `dfr open` and things like `into df` were renamed `dfr
into-df`. I'm sure we can optimize naming a bit, but it seems to compile
now.

# User-Facing Changes

All dataframe commands are prefixed with dfr.

# 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-08 15:52:57 -06:00
f9b5d8bc5e Add comment explaining background thread usage for plugin calls (#7878)
~~I happened to be reviewing our uses of `thread::spawn()` and came to
the conclusion that we're spawning a thread unnecessarily for plugin
calls. We were basically doing this:~~

~~1. Spawn a background thread to send data to the plugin over stdin~~
~~2. Immediately do a blocking wait for the plugin's response~~

~~As far as I can tell, there's no point in spawning a thread for 1 (and
it may harm error handling) given that we're blocking right away for the
response.~~

**Update:** the logic is correct, as confirmed by @WindSoilder
[here](https://discord.com/channels/601130461678272522/855947301380947968/1072743414795350037).
I've added a comment explaining the thread usage.
2023-02-08 08:53:44 -08:00
2917c045fb Bump actions-rust-lang/setup-rust-toolchain from 1.3.5 to 1.3.7 (#7979) 2023-02-08 13:03:05 +00:00
6e6ef862c5 Address #7997 (#8000)
Hi there,

The case which was presented must be addressed.

But I did not test it properly...
I'd encourage you to do so.

Take care.

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-02-07 20:01:31 -06:00
a7fdca05c6 http: add --insecure flag to http get, share common code (#7992)
# Description

I factorized the HTTP client from HTTP Post and HTTP Get into a common
file, in order to reduce the code duplication. This PR has to be looked
commit by commit.

# User-Facing Changes

A new option has been to HTTP Get: `--insecure`. This option was already
available for HTTP Post command.

# 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-07 14:22:19 -08:00
ddc33dc74a Fix imported virtualenv testsuite (#8001)
# Description

Patch `pyproject.toml` to ignore the checking of coverage level as we
only run part of the test suite affecting nushell.
2023-02-07 23:14:17 +01:00
a562f492e3 Windows: handle illegal filenames a little better (#7999)
This PR is an incremental improvement to `ls` when it encounters
'illegal' file paths on Windows. Related:
https://github.com/nushell/nushell/issues/7869

## Context

We have trouble with filenames that Windows doesn't like, for example
[files with a `.` at the end of their
name](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions).
To make a long story short, the Rust stdlib and several Win32 APIs will
choke if asked to do something with an illegal filepath. This is a
problem because files with illegal names can be created via other means
(like `touch foo.` in MINGW bash).

Previously `ls` would fail completely in a directory with a bad file,
which isn't great. After this PR, bad files get included in `ls` results
but without any metadata columns. This is not quite where we want to be
— eventually we want to be able to display file metadata for _all_ files
(even naughty ones) — but it's an improvement on the status quo.

### Before


![image](https://user-images.githubusercontent.com/26268125/217340906-26afd6d3-0ec3-454f-bed4-2bfcc9cf3a2f.png)

### After


![image](https://user-images.githubusercontent.com/26268125/217344373-6b81cc39-50b8-4390-8061-3e570502a784.png)

## Future work

Try the workarounds @ChrisDenton suggested:
https://github.com/nushell/nushell/issues/7869#issuecomment-1405977221

Some info on verbatim paths:
https://users.rust-lang.org/t/understanding-windows-paths/58583

## Testing

I tried to write a test for this, but it looks like our testing sandbox
can't create files with illegal filenames.😔 Here's the code in case it
proves useful someday:

```rust
/// Windows doesn't like certain file names, like file names ending with a period:
/// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
/// However, those files can still be created with tools like MINGW bash.
/// We may not be able to get full metadata for those files, but we should test that we can at least include them in ls results
#[test]
#[cfg(windows)]
fn can_list_illegal_files() {
    Playground::setup("ls_test_all_columns", |dirs, sandbox| {
        sandbox.with_files(vec![
            EmptyFile("foo"),
            EmptyFile("bar."),
            EmptyFile("baz"),
        ]);

        let actual = nu!(
            cwd: dirs.test(),
            "ls | length"
        );
        assert_eq!(actual.out, "3");

        let actual = nu!(
            cwd: dirs.test(),
            "ls"
        );
        assert_eq!(actual.out, "1");

        let actual = nu!(
            cwd: dirs.test(),
            "ls | where {|f| $f.name | str ends-with 'bar.'} | length"
        );
        assert_eq!(actual.out, "1");
    })
}
```
2023-02-07 12:30:37 -08:00
58f0d0b945 Fix $nu path separators on Windows (#7996)
I noticed that `$nu.loginshell-path` was using backward *and* forward
slashes on Windows.

#### Before
`C:\Users\reill\AppData\Roaming\nushell/login.nu`

#### After
`C:\Users\reill\AppData\Roaming\nushell\login.nu`

Fixed up 2 other similar issues while I was at it.
2023-02-07 11:50:39 -08:00
67d1249b2b Validate input range of du flags (#7962)
# Description
Fix #7953
Fix flags on `du` which should be positive and added some tests. 

# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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-06 21:34:32 +01:00
66e5e42fb1 report which datetime couldn't be converted (#7980)
# Description

This PR will help report a bad date that can't be converted where the
error message says `* Unable to parse datetime`. This is helpful when
you're converting a big table and it fails somewhere that you really
can't see. I put it in `[]` so that when it's null, you can see that
there should be something there.

Before:
```
> 'Tue 1 0' | into datetime 
Error: nu:🐚:datetime_parse_error (link)

  × Unable to parse datetime
   ╭─[entry #1:1:1]
 1 │ 'Tue 1 0' | into datetime
   · ────┬────
   ·     ╰── datetime parsing failed
   ╰────
  help: Examples of supported inputs:
         * "5 pm"
         * "2020/12/4"
         * "2020.12.04 22:10 +2"
         * "2020-04-12 22:10:57 +02:00"
         * "2020-04-12T22:10:57.213231+02:00"
         * "Tue, 1 Jul 2003 10:52:37 +0200"
```
After:
```
> 'Tue 1 0' | into datetime
Error: nu:🐚:datetime_parse_error (link)

  × Unable to parse datetime: [Tue 1 0].
   ╭─[entry #4:1:1]
 1 │ 'Tue 1 0' | into datetime
   · ────┬────
   ·     ╰── datetime parsing failed
   ╰────
  help: Examples of supported inputs:
         * "5 pm"
         * "2020/12/4"
         * "2020.12.04 22:10 +2"
         * "2020-04-12 22:10:57 +02:00"
         * "2020-04-12T22:10:57.213231+02:00"
         * "Tue, 1 Jul 2003 10:52:37 +0200"
```

# User-Facing Changes

New format for the error 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.
2023-02-06 14:17:07 -06:00
1f01b6438f Added fix for #7970 - Upgraded toml crate version from version from 0.5.8 to 0.7.1 for package nu-command (#7990)
# Description

Added fix for #7970 - Upgraded toml crate version from version from
0.5.8 to 0.7.1 for package nu-command

# Tests + Formatting

Added two tests to support the toml upgrade.

- `cargo test --package nu-command --lib -- formats::from::toml::tests
--nocapture`

Executed all tests.

- `cargo test --workspace`

---------

Co-authored-by: Nitin Londhe <nitin.londhe@genmills.com>
2023-02-06 14:15:14 -06:00
bea7ec33c1 Update few examples of math commands (#7987)
# Description

I just updated a few examples linked to math commands.

I used the character of pi where possible, and I updated one example
since the example was misleading IMO (for the tau command).

# User-Facing Changes

Only examples have been updated, there is no real user 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-06 13:43:00 +01:00
b5561f35b9 Bump which from 4.3.0 to 4.4.0 (#7974) 2023-02-06 10:43:28 +00:00
b796cda060 Test return in reduce closure from #7961 (#7973)
# Description

Functionality added by @nabacg in #7961 already

h/t @YuriGeinishO for the example in #7933

Closes #7933


# User-Facing Changes

None

# Tests + Formatting

+1 end to end example
2023-02-06 11:01:08 +01:00
4c308b7f2f Fix def-env docs according to docs#761 (#7972)
See nushell/nushell.github.io#761

# User-Facing Changes

Docs reflect up-to-date reality

Co-authored-by: Canop <cano.petrole@gmail.com>
2023-02-06 11:00:44 +01:00
d50eb9b41b Bump fs_extra from 1.2.0 to 1.3.0 (#7976) 2023-02-06 09:59:58 +00:00
9168301369 Clarify two config fields (#7969)
In particular this makes the `show_banner` field more findable.

Users may search for "welcome" and "startup" which appear
in the banner.
2023-02-06 00:01:23 +01:00
e8d930f659 Reorder help <keyword> priority (#7929)
# Description

`help <keyword>` will now search for `<keyword>` in aliases first, then
commands. This matches the way the parser resolves aliases before
commands.

# User-Facing Changes

Not significant
2023-02-05 23:51:09 +01:00
aef88aa03e Load env pwd (#7963)
# Description

Fixes #7940
avoid `load-env` to change PWD 

# User-Facing Changes

`{"PWD": whatever} | load-env` now fails
2023-02-05 23:40:46 +01:00
ec4370069a Bump tokio from 1.24.1 to 1.25.0 (#7958) 2023-02-05 21:22:37 +00:00
c79ece2b21 Extract run blocks into functions (#7964)
As usual, Rust optimizes a bit less if more function boundaries are
introduced.
However, in my opinion, being able to comprehend the decision tree beats
a couple of string allocations.
2023-02-05 22:20:35 +01:00
99076af18b Use imported names in Command::run signatures (#7967)
# Description

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

I opened this PR to unify the run command method. It's mainly to improve
consistency across the tree.

# 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-05 22:17:46 +01:00
a0e3ad2b70 return in reduce command closure (#7961)
# Description

Fix for #7933. I've read through code and found the obvious difference
between them, where `each` command calls eval_with_early_return
e89e734ca2/crates/nu-command/src/filters/each.rs (L158),
while `reduce` command uses eval_block
e89e734ca2/crates/nu-command/src/filters/reduce.rs (L143)

That simple change seems to resolve the problem. 

# User-Facing Changes

Allows the use of `return` in reduce closures, as per example in #7933
description. Arguably it's restoring consistency, than changing user
interface.

```
[1, 2] | reduce --fold null { |it, state|                                                           
::: if $it == 1 {
:::     return 10
::: }
::: return ($it * $state)
::: }
20
```

# 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-04 16:41:54 -06:00
e89e734ca2 Only abbreviate to "[table x rows]" if every value is a record (#7922)
# Description

Closes #6768.

BEFORE:
```
〉{ foo: [{a:1, b:2},2,3,4,5] }
╭─────┬────────────────╮
│ foo │ [table 5 rows] │
╰─────┴────────────────╯
```
AFTER:
```
〉{ foo: [{a:1, b:2},2,3,4,5] }
╭─────┬────────────────╮
│ foo │ [list 5 items] │
╰─────┴────────────────╯
```

# 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-02 17:03:36 -06:00
9945241b77 Remove deprecated --numbered flag from four commands (#7777)
# Description

Remove `--numbered` from ~~`for`~~, `each`, `par-each`, `reduce` and
`each while`. These all provide indexes (numbering) via the optional
second param to their closures.

EDIT: Closes #6986.

# User-Facing Changes

Every command that had `--numbered` listed as "deprecated" in their help
docs is affected.

# 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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-02-02 16:59:58 -06:00
215ed141e7 Fix code in benchmarks (#7949)
# Description

Broken after #7415

We currently don't try to build the benchmarks in the CI thus this
slipped through the cracks.


# User-Facing Changes

None

# Tests + Formatting

Compile check is currently missing, but working towards that
2023-02-02 23:07:35 +01:00
f189ee67a1 Fix copy paste error (#7945) 2023-02-02 12:50:27 -06:00
babc7d3baf clean up the registry query output (#7939)
# Description

This cleans up the `registry query` output so that it's more usable.

Before:

![image](https://user-images.githubusercontent.com/343840/216129871-7cadcb68-a289-4e29-8857-6fc20b6a57f7.png)

After:

![image](https://user-images.githubusercontent.com/343840/216129814-70021706-f58a-4647-b5f1-a0e30f5fae16.png)


# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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-02 07:10:38 -06:00
8f4807020f make do -i works with liststream (#7889)
# Description

Fixes: #7874 

It's because `do -i` doesn't handles `Pipeline::ListStream`
data(especially there is Value::Error inside the stream)

To fix it, we need to iterate through `ListStream`, check if there is
`Value::Error`. If so, just returns `Pipeline::empty()`

# User-Facing Changes

```
help commands | find arg | get search_terms | do -i { ansi strip }
```

No longer raises error.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass

# 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-02 00:04:53 +01:00
31e1410191 respect use_ansi_coloring configuration (#7912)
# Description

Use the `use_ansi_coloring` configuration point to decide whether the
output will have colors, where possible.

Related: https://github.com/nushell/nushell/issues/7676


![image](https://user-images.githubusercontent.com/749306/215435128-cbf5f4b8-aafa-4718-bf23-3f0fd19b63ba.png)

- [x] `grid -c`
- [x] `perf()`

# 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-02 00:03:05 +01:00
24d7227e27 ensure that when nu evaluates files, it allows early returns (#7415)
# Description

Fixes #7301.

# User-Facing Changes

`return` can now be used in scripts without explicit `def main`.

# Tests + Formatting

Don't forget to add tests that cover your changes. (I'm not sure how to
test this.)

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-02 00:02:27 +01:00
c130ca1bc6 Fix: dst error on cp command (#7895)
Fixes #7693 

On `cp` commands there were two error which pass error message with
invalid detail about source and destination files . there error were for
Not exist file and Permission denied .

Examples:
  Before :
Copy `source_file_valid` to `destination_invalid_dir` throw this error ;
`copy file "/source_file_valid" failed: No such file or directory (os
error 2) `

 After this PR it will throw this if destination will be invalid :
`copying to destination "/destination_invalid_dir" failed: No such file
or directory (os error 2) `

it was for Permission denied too .

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-02-01 21:48:21 +01:00
4db960c0a6 use newer reedline (once available) (#7919)
# Description

Use newer reedline that fixes the code completion crash in
https://github.com/nushell/nushell/issues/7885 by subtracting from the
insertion point if the suggestion is shorter than the editor span.

Closes https://github.com/nushell/nushell/issues/7885

Depends on https://github.com/nushell/reedline/pull/534

# User-Facing Changes


# Tests + Formatting

Tested in reedline.

- `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: sholderbach <sholderbach@users.noreply.github.com>
2023-02-01 21:46:47 +01:00
d13ce2aec9 add ability to view-source on closures (#7935)
closes https://github.com/nushell/nushell/issues/7934
2023-02-01 20:48:27 +02:00
5e957ecda6 Bump to 0.75.1 development version (#7930)
To demark development work or to be used with a point release in an
emergency
2023-01-31 23:55:29 +01:00
516 changed files with 7881 additions and 4070 deletions

View File

@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.4.2
- name: cargo fmt
run: cargo fmt --all -- --check
@ -77,7 +77,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.4.2
- name: Tests
run: cargo test --workspace --profile ci --exclude nu_plugin_* ${{ matrix.flags }}
@ -101,7 +101,7 @@ jobs:
- uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.4.2
- name: Install Nushell
run: cargo install --locked --path=. --profile ci --no-default-features
@ -119,7 +119,12 @@ jobs:
shell: bash
- name: Test Nushell in virtualenv
run: cd virtualenv && tox -e ${{ matrix.py }} -- -k nushell
run: |
cd virtualenv
# We need to disable failing on coverage levels.
nu -c "open pyproject.toml | upsert tool.coverage.report.fail_under 1 | save patchproject.toml"
mv patchproject.toml pyproject.toml
tox -e ${{ matrix.py }} -- -k nushell
shell: bash
# Build+test plugins on their own, without the rest of Nu. This helps with CI parallelization and
@ -141,10 +146,47 @@ jobs:
- uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.4.2
- name: Clippy
run: cargo clippy --package nu_plugin_* ${{ matrix.flags }} -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
- name: Tests
run: cargo test --profile ci --package nu_plugin_*
nu-coverage:
needs: nu-tests
env:
NUSHELL_CARGO_TARGET: ci
strategy:
fail-fast: true
matrix:
platform: [windows-latest, ubuntu-20.04]
rust:
- stable
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.4.2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Tests
shell: bash
run: |
source <(cargo llvm-cov show-env --export-prefix) # Set the environment variables needed to get coverage.
cargo llvm-cov clean --workspace # Remove artifacts that may affect the coverage results.
cargo build --lib --bins --examples --workspace --profile ci
cargo test --lib --bins --examples --workspace --profile ci --exclude nu_plugin_* ${{ matrix.flags }}
cargo llvm-cov report --profile ci --lcov --output-path lcov.info
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
with:
files: lcov.info

View File

@ -156,7 +156,7 @@ if $os in [$USE_UBUNTU, 'macos-latest'] {
cd $src; hr-line
# Wix need the binaries be stored in target/release/
cp -r $'($dist)/*' target/release/
cargo install cargo-wix --version 0.3.3
cargo install cargo-wix --version 0.3.4
cargo wix --no-build --nocapture --package nu --output $wixRelease
print $'archive: ---> ($wixRelease)';
echo $"archive=($wixRelease)" | save --append $env.GITHUB_OUTPUT

View File

@ -70,7 +70,7 @@ jobs:
echo "targets = ['${{matrix.target}}']" >> rust-toolchain.toml
- name: Setup Rust toolchain and cache
uses: actions-rust-lang/setup-rust-toolchain@v1.3.5
uses: actions-rust-lang/setup-rust-toolchain@v1.4.2
- name: Setup Nushell
uses: hustcer/setup-nu@v3

View File

@ -9,5 +9,5 @@ jobs:
- name: Checkout Actions Repository
uses: actions/checkout@v2
- name: Check spelling of book
- name: Check spelling
uses: crate-ci/typos@master

250
Cargo.lock generated
View File

@ -1078,6 +1078,12 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "dlv-list"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257"
[[package]]
name = "doc-comment"
version = "0.3.3"
@ -1341,9 +1347,9 @@ dependencies = [
[[package]]
name = "fs_extra"
version = "1.2.0"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
[[package]]
name = "fsevent"
@ -1810,9 +1816,9 @@ dependencies = [
[[package]]
name = "ical"
version = "0.7.0"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a9f7215ad0d77e69644570dee000c7678a47ba7441062c1b5f918adde0d73cf"
checksum = "356d82bd58997815d55ea6f9081bd4cac149e50ca943f7a4f7c050fec7271c1f"
dependencies = [
"thiserror",
]
@ -2566,6 +2572,15 @@ dependencies = [
"nom",
]
[[package]]
name = "nom8"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8"
dependencies = [
"memchr",
]
[[package]]
name = "notify"
version = "4.0.17"
@ -2604,7 +2619,7 @@ dependencies = [
[[package]]
name = "nu"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"assert_cmd",
"atty",
@ -2659,7 +2674,7 @@ dependencies = [
[[package]]
name = "nu-cli"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"atty",
"chrono",
@ -2688,7 +2703,7 @@ dependencies = [
[[package]]
name = "nu-color-config"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"nu-ansi-term",
"nu-engine",
@ -2702,7 +2717,7 @@ dependencies = [
[[package]]
name = "nu-command"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"Inflector",
"alphanumeric-sort",
@ -2720,7 +2735,6 @@ dependencies = [
"digest",
"dirs-next",
"dtparse",
"eml-parser",
"encoding_rs",
"fancy-regex",
"filesize",
@ -2728,7 +2742,6 @@ dependencies = [
"fs_extra",
"hamcrest2",
"htmlescape",
"ical",
"indexmap",
"indicatif",
"is-root",
@ -2764,6 +2777,7 @@ dependencies = [
"percent-encoding",
"polars",
"powierza-coefficient",
"print-positions",
"proptest",
"quick-xml 0.27.1",
"quickcheck",
@ -2779,32 +2793,33 @@ dependencies = [
"rust-embed",
"same-file",
"serde",
"serde_ini",
"serde_urlencoded",
"serde_yaml",
"sha2",
"shadow-rs",
"sqlparser",
"sysinfo",
"tabled",
"terminal_size 0.2.1",
"thiserror",
"titlecase",
"toml",
"toml 0.7.2",
"trash",
"umask",
"unicode-segmentation",
"unicode-width",
"url",
"users 0.11.0",
"uuid",
"wax",
"which",
"windows",
"winreg",
"winreg 0.11.0",
]
[[package]]
name = "nu-engine"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"chrono",
"nu-glob",
@ -2817,7 +2832,7 @@ dependencies = [
[[package]]
name = "nu-explore"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"ansi-str 0.7.2",
"crossterm 0.24.0",
@ -2837,14 +2852,14 @@ dependencies = [
[[package]]
name = "nu-glob"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"doc-comment",
]
[[package]]
name = "nu-json"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"linked-hash-map",
"num-traits",
@ -2853,7 +2868,7 @@ dependencies = [
[[package]]
name = "nu-parser"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"bytesize",
"chrono",
@ -2870,7 +2885,7 @@ dependencies = [
[[package]]
name = "nu-path"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"dirs-next",
"omnipath",
@ -2879,7 +2894,7 @@ dependencies = [
[[package]]
name = "nu-plugin"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"bincode",
"nu-engine",
@ -2892,7 +2907,7 @@ dependencies = [
[[package]]
name = "nu-pretty-hex"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"heapless",
"nu-ansi-term",
@ -2901,7 +2916,7 @@ dependencies = [
[[package]]
name = "nu-protocol"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"byte-unit",
"chrono",
@ -2925,7 +2940,7 @@ dependencies = [
[[package]]
name = "nu-system"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"atty",
"chrono",
@ -2943,7 +2958,7 @@ dependencies = [
[[package]]
name = "nu-table"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"atty",
"json_to_table",
@ -2958,7 +2973,7 @@ dependencies = [
[[package]]
name = "nu-term-grid"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"nu-utils",
"unicode-width",
@ -2966,7 +2981,7 @@ dependencies = [
[[package]]
name = "nu-test-support"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"getset",
"hamcrest2",
@ -2976,11 +2991,12 @@ dependencies = [
"num-format",
"once_cell",
"tempfile",
"which",
]
[[package]]
name = "nu-utils"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"crossterm_winapi",
"log",
@ -3002,15 +3018,28 @@ dependencies = [
[[package]]
name = "nu_plugin_example"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"nu-plugin",
"nu-protocol",
]
[[package]]
name = "nu_plugin_formats"
version = "0.1.0"
dependencies = [
"eml-parser",
"ical",
"indexmap",
"nu-engine",
"nu-plugin",
"nu-protocol",
"rust-ini",
]
[[package]]
name = "nu_plugin_gstat"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"git2",
"nu-engine",
@ -3020,7 +3049,7 @@ dependencies = [
[[package]]
name = "nu_plugin_inc"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"nu-plugin",
"nu-protocol",
@ -3029,7 +3058,7 @@ dependencies = [
[[package]]
name = "nu_plugin_query"
version = "0.75.0"
version = "0.76.0"
dependencies = [
"gjson",
"nu-engine",
@ -3270,9 +3299,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.22.0+1.1.1q"
version = "111.25.0+1.1.1t"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f31f0d509d1c1ae9cada2f9539ff8f37933831fd5098879e482aa687d659853"
checksum = "3173cd3626c43e3854b1b727422a276e568d9ec5fe8cec197822cf52cfb743d6"
dependencies = [
"cc",
]
@ -3291,6 +3320,16 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "ordered-multimap"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a"
dependencies = [
"dlv-list",
"hashbrown 0.12.3",
]
[[package]]
name = "os_str_bytes"
version = "6.4.1"
@ -3856,6 +3895,15 @@ dependencies = [
"yansi",
]
[[package]]
name = "print-positions"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df593470e3ef502e48cb0cfc9a3a61e5f61e967b78e1ed35a67ac615cfbd208"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@ -3912,9 +3960,9 @@ dependencies = [
[[package]]
name = "proptest"
version = "1.0.0"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0d9cc07f18492d879586c92b485def06bc850da3118075cd45d50e9c95b0e5"
checksum = "29f1b898011ce9595050a68e60f90bad083ff2987a695a42357134c8381fba70"
dependencies = [
"bit-set",
"bitflags",
@ -3928,6 +3976,7 @@ dependencies = [
"regex-syntax",
"rusty-fork",
"tempfile",
"unarray",
]
[[package]]
@ -4152,9 +4201,9 @@ dependencies = [
[[package]]
name = "reedline"
version = "0.15.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da60f4ca4517626e4621dba4fb252069572d5bfaf41efb96dfa5c93f39f2e978"
checksum = "a02723e44c03f5ef62ad35665a43cfa1df3b78cbb75e31ea9ddc6d2f0d9b4658"
dependencies = [
"chrono",
"crossterm 0.24.0",
@ -4238,15 +4287,9 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"winreg",
"winreg 0.10.1",
]
[[package]]
name = "result"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560"
[[package]]
name = "riscv"
version = "0.7.0"
@ -4292,18 +4335,18 @@ dependencies = [
[[package]]
name = "roxmltree"
version = "0.17.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "461c9b944cd1481b793aeef26d1008b5d1fdeb00e01296cb4ff08aed511c7383"
checksum = "d8f595a457b6b8c6cda66a48503e92ee8d19342f905948f29c383200ec9eb1d8"
dependencies = [
"xmlparser",
]
[[package]]
name = "rstest"
version = "0.15.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9c9dc66cc29792b663ffb5269be669f1613664e69ad56441fdb895c2347b930"
checksum = "b07f2d176c472198ec1e6551dc7da28f1c089652f66a7b722676c2238ebc0edf"
dependencies = [
"rstest_macros",
"rustc_version 0.4.0",
@ -4311,15 +4354,16 @@ dependencies = [
[[package]]
name = "rstest_macros"
version = "0.14.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5015e68a0685a95ade3eee617ff7101ab6a3fc689203101ca16ebc16f2b89c66"
checksum = "7229b505ae0706e64f37ffc54a9c163e11022a6636d58fe1f3f52018257ff9f7"
dependencies = [
"cfg-if 1.0.0",
"proc-macro2",
"quote",
"rustc_version 0.4.0",
"syn",
"unicode-ident",
]
[[package]]
@ -4370,6 +4414,16 @@ dependencies = [
"walkdir",
]
[[package]]
name = "rust-ini"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df"
dependencies = [
"cfg-if 1.0.0",
"ordered-multimap",
]
[[package]]
name = "rust_decimal"
version = "1.26.1"
@ -4572,17 +4626,6 @@ dependencies = [
"syn",
]
[[package]]
name = "serde_ini"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139"
dependencies = [
"result",
"serde",
"void",
]
[[package]]
name = "serde_json"
version = "1.0.85"
@ -4594,6 +4637,15 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
dependencies = [
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@ -4986,9 +5038,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.27.7"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "975fe381e0ecba475d4acff52466906d95b153a40324956552e027b2a9eaa89e"
checksum = "727220a596b4ca0af040a07091e49f5c105ec8f2592674339a5bf35be592f76e"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys",
@ -5109,18 +5161,18 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
[[package]]
name = "thiserror"
version = "1.0.37"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.37"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
dependencies = [
"proc-macro2",
"quote",
@ -5212,9 +5264,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.24.1"
version = "1.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae"
checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af"
dependencies = [
"autocfg",
"bytes",
@ -5260,6 +5312,40 @@ dependencies = [
"serde",
]
[[package]]
name = "toml"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]]
name = "toml_datetime"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.19.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5"
dependencies = [
"indexmap",
"nom8",
"serde",
"serde_spanned",
"toml_datetime",
]
[[package]]
name = "tower-service"
version = "0.3.2"
@ -5363,6 +5449,12 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46b0c16eadfb312c7acd6970fc97d1f3152eb536714a2ff72ca09a92cae6fa67"
[[package]]
name = "unarray"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"
[[package]]
name = "unicase"
version = "2.6.0"
@ -5405,9 +5497,9 @@ dependencies = [
[[package]]
name = "unicode-segmentation"
version = "1.10.0"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
@ -5695,9 +5787,9 @@ dependencies = [
[[package]]
name = "which"
version = "4.3.0"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b"
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
dependencies = [
"either",
"libc",
@ -5880,13 +5972,23 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "winreg"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76a1a57ff50e9b408431e8f97d5456f2807f8eb2a2cd79b06068fc87f8ecf189"
dependencies = [
"cfg-if 1.0.0",
"winapi 0.3.9",
]
[[package]]
name = "winres"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
dependencies = [
"toml",
"toml 0.5.9",
]
[[package]]

View File

@ -10,7 +10,7 @@ license = "MIT"
name = "nu"
repository = "https://github.com/nushell/nushell"
rust-version = "1.60"
version = "0.75.0"
version = "0.76.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -35,6 +35,7 @@ members = [
"crates/nu_plugin_example",
"crates/nu_plugin_query",
"crates/nu_plugin_custom_values",
"crates/nu_plugin_formats",
"crates/nu-utils",
]
@ -45,21 +46,22 @@ ctrlc = "3.2.1"
log = "0.4"
miette = { version = "5.5.0", features = ["fancy-no-backtrace"] }
nu-ansi-term = "0.46.0"
nu-cli = { path = "./crates/nu-cli", version = "0.75.0" }
nu-color-config = { path = "./crates/nu-color-config", version = "0.75.0" }
nu-command = { path = "./crates/nu-command", version = "0.75.0" }
nu-engine = { path = "./crates/nu-engine", version = "0.75.0" }
nu-json = { path = "./crates/nu-json", version = "0.75.0" }
nu-parser = { path = "./crates/nu-parser", version = "0.75.0" }
nu-path = { path = "./crates/nu-path", version = "0.75.0" }
nu-plugin = { path = "./crates/nu-plugin", optional = true, version = "0.75.0" }
nu-pretty-hex = { path = "./crates/nu-pretty-hex", version = "0.75.0" }
nu-protocol = { path = "./crates/nu-protocol", version = "0.75.0" }
nu-system = { path = "./crates/nu-system", version = "0.75.0" }
nu-table = { path = "./crates/nu-table", version = "0.75.0" }
nu-term-grid = { path = "./crates/nu-term-grid", version = "0.75.0" }
nu-utils = { path = "./crates/nu-utils", version = "0.75.0" }
reedline = { version = "0.15.0", features = ["bashisms", "sqlite"] }
nu-cli = { path = "./crates/nu-cli", version = "0.76.0" }
nu-color-config = { path = "./crates/nu-color-config", version = "0.76.0" }
nu-command = { path = "./crates/nu-command", version = "0.76.0" }
nu-engine = { path = "./crates/nu-engine", version = "0.76.0" }
nu-json = { path = "./crates/nu-json", version = "0.76.0" }
nu-parser = { path = "./crates/nu-parser", version = "0.76.0" }
nu-path = { path = "./crates/nu-path", version = "0.76.0" }
nu-plugin = { path = "./crates/nu-plugin", optional = true, version = "0.76.0" }
nu-pretty-hex = { path = "./crates/nu-pretty-hex", version = "0.76.0" }
nu-protocol = { path = "./crates/nu-protocol", version = "0.76.0" }
nu-system = { path = "./crates/nu-system", version = "0.76.0" }
nu-table = { path = "./crates/nu-table", version = "0.76.0" }
nu-term-grid = { path = "./crates/nu-term-grid", version = "0.76.0" }
nu-utils = { path = "./crates/nu-utils", version = "0.76.0" }
reedline = { version = "0.16.0", features = ["bashisms", "sqlite"] }
rayon = "1.6.1"
is_executable = "1.0.1"
@ -76,18 +78,23 @@ signal-hook = { version = "0.3.14", default-features = false }
winres = "0.1"
[target.'cfg(target_family = "unix")'.dependencies]
nix = { version = "0.25", default-features = false, features = ["signal", "process", "fs", "term"] }
nix = { version = "0.25", default-features = false, features = [
"signal",
"process",
"fs",
"term",
] }
atty = "0.2"
[dev-dependencies]
nu-test-support = { path = "./crates/nu-test-support", version = "0.75.0" }
nu-test-support = { path = "./crates/nu-test-support", version = "0.76.0" }
tempfile = "3.2.0"
assert_cmd = "2.0.2"
criterion = "0.4"
pretty_assertions = "1.0.0"
serial_test = "1.0.0"
hamcrest2 = "0.3.0"
rstest = { version = "0.15.0", default-features = false }
rstest = { version = "0.16.0", default-features = false }
itertools = "0.10.3"
[features]
@ -143,6 +150,7 @@ debug = false
[[bin]]
name = "nu"
path = "src/main.rs"
bench = false
# To use a development version of a dependency please use a global override here
# changing versions in each sub-crate of the workspace is tedious

View File

@ -6,6 +6,7 @@
[![@nu_shell](https://img.shields.io/badge/twitter-@nu_shell-1DA1F3?style=flat-square)](https://twitter.com/nu_shell)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/nushell/nushell)
![GitHub contributors](https://img.shields.io/github/contributors/nushell/nushell)
[![codecov](https://codecov.io/github/nushell/nushell/branch/main/graph/badge.svg?token=JheS8qu2II)](https://codecov.io/github/nushell/nushell)
A new type of shell.
@ -32,7 +33,7 @@ This project has reached a minimum-viable-product level of quality. Many people
## Learning About Nu
The [Nushell book](https://www.nushell.sh/book/) is the primary source of Nushell documentation. You can find [a full list of Nu commands in the book](https://www.nushell.sh/book/command_reference.html), and we have many examples of using Nu in our [cookbook](https://www.nushell.sh/cookbook/).
The [Nushell book](https://www.nushell.sh/book/) is the primary source of Nushell documentation. You can find [a full list of Nu commands in the book](https://www.nushell.sh/commands/), and we have many examples of using Nu in our [cookbook](https://www.nushell.sh/cookbook/).
We're also active on [Discord](https://discord.gg/NtAbbGn) and [Twitter](https://twitter.com/nu_shell); come and chat with us!

View File

@ -46,6 +46,7 @@ fn parser_benchmarks(c: &mut Criterion) {
get_default_env().as_bytes(),
"default_env.nu",
PipelineData::empty(),
false,
)
})
});
@ -65,6 +66,7 @@ fn parser_benchmarks(c: &mut Criterion) {
get_default_config().as_bytes(),
"default_config.nu",
PipelineData::empty(),
false,
)
})
});
@ -81,6 +83,7 @@ fn eval_benchmarks(c: &mut Criterion) {
get_default_env().as_bytes(),
"default_env.nu",
PipelineData::empty(),
false,
)
})
});
@ -100,6 +103,7 @@ fn eval_benchmarks(c: &mut Criterion) {
get_default_config().as_bytes(),
"default_config.nu",
PipelineData::empty(),
false,
)
})
});

View File

@ -12,6 +12,7 @@ let plugins = [
nu_plugin_query,
nu_plugin_example,
nu_plugin_custom_values,
nu_plugin_formats,
]
for plugin in $plugins {

17
codecov.yml Normal file
View File

@ -0,0 +1,17 @@
coverage:
status:
project:
default:
target: 55%
threshold: 2%
patch:
default:
informational: true
comment:
layout: reach, diff, files
behavior: default
require_base: yes
require_head: yes
after_n_builds: 2

54
coverage-local.nu Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env nu
let start = (date now)
# Script to generate coverage locally
#
# Output: `lcov.info` file
#
# Relies on `cargo-llvm-cov`. Install via `cargo install cargo-llvm-cov`
# https://github.com/taiki-e/cargo-llvm-cov
# You probably have to run `cargo llvm-cov clean` once manually,
# as you have to confirm to install additional tooling for your rustup toolchain.
# Else the script might stall waiting for your `y<ENTER>`
# Some of the internal tests rely on the exact cargo profile
# (This is somewhat criminal itself)
# but we have to signal to the tests that we use the `ci` `--profile`
let-env NUSHELL_CARGO_TARGET = "ci"
# Manual gathering of coverage to catch invocation of the `nu` binary.
# This is relevant for tests using the `nu!` macro from `nu-test-support`
# see: https://github.com/taiki-e/cargo-llvm-cov#get-coverage-of-external-tests
print "Setting up environment variables for coverage"
# Enable LLVM coverage tracking through environment variables
# show env outputs .ini/.toml style description of the variables
# In order to use from toml, we need to make sure our string literals are single quoted
# This is especially important when running on Windows since "C:\blah" is treated as an escape
cargo llvm-cov show-env | str replace (char dq) (char sq) -a | from toml | load-env
print "Cleaning up coverage data"
cargo llvm-cov clean --workspace
print "Building with workspace and profile=ci"
# Apparently we need to explicitly build the necessary parts
# using the `--profile=ci` is basically `debug` build with unnecessary symbols stripped
# leads to smaller binaries and potential savings when compiling and running
cargo build --workspace --profile=ci
print "Running tests with --workspace and profile=ci"
cargo test --workspace --profile=ci
# You need to provide the used profile to find the raw data
print "Generating coverage report as lcov.info"
cargo llvm-cov report --lcov --output-path lcov.info --profile=ci
let end = (date now)
$"Coverage generation took ($end - $start)."
# To display the coverage in your editor see:
#
# - https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
# - https://github.com/umaumax/vim-lcov
# - https://github.com/andythigpen/nvim-coverage (probably needs some additional config)

38
coverage-local.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Script to generate coverage locally
#
# Output: `lcov.info` file
#
# Relies on `cargo-llvm-cov`. Install via `cargo install cargo-llvm-cov`
# https://github.com/taiki-e/cargo-llvm-cov
# You probably have to run `cargo llvm-cov clean` once manually,
# as you have to confirm to install additional tooling for your rustup toolchain.
# Else the script might stall waiting for your `y<ENTER>`
# Some of the internal tests rely on the exact cargo profile
# (This is somewhat criminal itself)
# but we have to signal to the tests that we use the `ci` `--profile`
export NUSHELL_CARGO_TARGET=ci
# Manual gathering of coverage to catch invocation of the `nu` binary.
# This is relevant for tests using the `nu!` macro from `nu-test-support`
# see: https://github.com/taiki-e/cargo-llvm-cov#get-coverage-of-external-tests
# Enable LLVM coverage tracking through environment variables
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace
# Apparently we need to explicitly build the necessary parts
# using the `--profile=ci` is basically `debug` build with unnecessary symbols stripped
# leads to smaller binaries and potential savings when compiling and running
cargo build --workspace --profile=ci
cargo test --workspace --profile=ci
# You need to provide the used profile to find the raw data
cargo llvm-cov report --lcov --output-path lcov.info --profile=ci
# To display the coverage in your editor see:
#
# - https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
# - https://github.com/umaumax/vim-lcov
# - https://github.com/andythigpen/nvim-coverage (probably needs some additional config)

View File

@ -5,22 +5,26 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli"
edition = "2021"
license = "MIT"
name = "nu-cli"
version = "0.75.0"
version = "0.76.0"
[lib]
bench = false
[dev-dependencies]
nu-test-support = { path = "../nu-test-support", version = "0.75.0" }
nu-command = { path = "../nu-command", version = "0.75.0" }
rstest = { version = "0.15.0", default-features = false }
nu-test-support = { path = "../nu-test-support", version = "0.76.0" }
nu-command = { path = "../nu-command", version = "0.76.0" }
rstest = { version = "0.16.0", default-features = false }
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.75.0" }
nu-path = { path = "../nu-path", version = "0.75.0" }
nu-parser = { path = "../nu-parser", version = "0.75.0" }
nu-protocol = { path = "../nu-protocol", version = "0.75.0" }
nu-utils = { path = "../nu-utils", version = "0.75.0" }
nu-engine = { path = "../nu-engine", version = "0.76.0" }
nu-path = { path = "../nu-path", version = "0.76.0" }
nu-parser = { path = "../nu-parser", version = "0.76.0" }
nu-protocol = { path = "../nu-protocol", version = "0.76.0" }
nu-utils = { path = "../nu-utils", version = "0.76.0" }
nu-ansi-term = "0.46.0"
nu-color-config = { path = "../nu-color-config", version = "0.75.0" }
reedline = { version = "0.15.0", features = ["bashisms", "sqlite"] }
nu-color-config = { path = "../nu-color-config", version = "0.76.0" }
reedline = { version = "0.16.0", features = ["bashisms", "sqlite"] }
atty = "0.2.14"
chrono = { default-features = false, features = ["std"], version = "0.4.23" }
@ -32,7 +36,7 @@ once_cell = "1.17.0"
log = "0.4"
miette = { version = "5.5.0", features = ["fancy-no-backtrace"] }
percent-encoding = "2"
sysinfo = "0.27.7"
sysinfo = "0.28.0"
thiserror = "1.0.31"
[features]

View File

@ -37,7 +37,8 @@ impl CommandCompletion {
) -> Vec<String> {
let mut executables = vec![];
let paths = self.engine_state.get_env_var("PATH");
// os agnostic way to get the PATH env var
let paths = self.engine_state.get_path_env_var();
if let Some(paths) = paths {
if let Ok(paths) = paths.as_list() {
@ -164,7 +165,7 @@ impl Completer for CommandCompletion {
.flattened
.iter()
.rev()
.skip_while(|x| x.0.end + offset > pos)
.skip_while(|x| x.0.end > pos)
.take_while(|x| {
matches!(
x.1,

View File

@ -111,18 +111,11 @@ impl NuCompleter {
}
fn completion_helper(&mut self, line: &str, pos: usize) -> Vec<Suggestion> {
// pos: is the position of the cursor in the shell input.
// e.g. lets say you have an alias -> `alias ll = ls -l` and you type in the shell:
// > ll -a | c
// and your cursor is right after `c` then `pos` = 9
let mut working_set = StateWorkingSet::new(&self.engine_state);
let mut offset = working_set.next_span_start();
let offset = working_set.next_span_start();
let (mut new_line, alias_offset) = try_find_alias(line.as_bytes(), &working_set);
// new_line: vector containing all alias "translations" so if it was `ll` now is `ls -l`.
// alias_offset:vector the offset between the name and the alias)
let initial_line = line.to_string(); // Entire line in the shell input.
let alias_total_offset: usize = alias_offset.iter().sum(); // the sum of all alias offsets.
let initial_line = line.to_string();
let alias_total_offset: usize = alias_offset.iter().sum();
new_line.insert(alias_total_offset + pos, b'a');
let pos = offset + pos;
let config = self.engine_state.get_config();
@ -163,22 +156,14 @@ impl NuCompleter {
most_left_variable(flat_idx, &working_set, flattened.clone());
// Create a new span
// if flat_idx == 0
let mut span_start = flat.0.start;
let mut span_end = flat.0.end - 1 - span_offset;
if flat_idx != 0 {
span_start = flat.0.start - span_offset;
span_end = flat.0.end - 1 - span_offset;
}
if span_end < span_start {
span_start = flat.0.start;
span_end = flat.0.end - 1;
offset += span_offset
}
let new_span = Span::new(span_start, span_end);
let new_span = if flat_idx == 0 {
Span::new(flat.0.start, flat.0.end - 1 - span_offset)
} else {
Span::new(
flat.0.start - span_offset,
flat.0.end - 1 - span_offset,
)
};
// Parses the prefix. Completion should look up to the cursor position, not after.
let mut prefix = working_set.get_span_contents(flat.0).to_vec();
@ -193,10 +178,6 @@ impl NuCompleter {
most_left_var.unwrap_or((vec![], vec![])),
);
if offset > new_span.start {
offset -= span_offset;
}
return self.process_completion(
&mut completer,
&working_set,

View File

@ -141,6 +141,16 @@ pub fn file_path_completion(
|| path.contains('#')
|| path.contains('(')
|| path.contains(')')
|| path.starts_with('0')
|| path.starts_with('1')
|| path.starts_with('2')
|| path.starts_with('3')
|| path.starts_with('4')
|| path.starts_with('5')
|| path.starts_with('6')
|| path.starts_with('7')
|| path.starts_with('8')
|| path.starts_with('9')
{
path = format!("`{path}`");
}

View File

@ -41,6 +41,7 @@ pub fn read_plugin_file(
&contents,
&plugin_filename,
PipelineData::empty(),
false,
);
}
}
@ -51,6 +52,7 @@ pub fn read_plugin_file(
file!(),
line!(),
column!(),
engine_state.get_config().use_ansi_coloring,
);
}
@ -93,6 +95,7 @@ pub fn eval_config_contents(
&contents,
&config_filename,
PipelineData::empty(),
false,
);
// Merge the environment in case env vars changed in the config

View File

@ -106,13 +106,21 @@ pub fn evaluate_file(
&file,
file_path_str,
PipelineData::empty(),
true,
) {
std::process::exit(1);
}
if !eval_source(engine_state, stack, args.as_bytes(), "<commandline>", input) {
if !eval_source(
engine_state,
stack,
args.as_bytes(),
"<commandline>",
input,
true,
) {
std::process::exit(1);
}
} else if !eval_source(engine_state, stack, &file, file_path_str, input) {
} else if !eval_source(engine_state, stack, &file, file_path_str, input, true) {
std::process::exit(1);
}

View File

@ -45,6 +45,7 @@ pub fn evaluate_repl(
entire_start_time: Instant,
) -> Result<()> {
use reedline::{FileBackedHistory, Reedline, Signal};
let use_color = engine_state.get_config().use_ansi_coloring;
// Guard against invocation without a connected terminal.
// reedline / crossterm event polling will fail without a connected tty
@ -72,6 +73,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
// seed env vars
@ -91,7 +93,14 @@ pub fn evaluate_repl(
.map(i64::from)
.unwrap_or(0);
engine_state.history_session_id = hist_sesh;
perf("setup reedline", start_time, file!(), line!(), column!());
perf(
"setup reedline",
start_time,
file!(),
line!(),
column!(),
use_color,
);
let config = engine_state.get_config();
@ -115,7 +124,14 @@ pub fn evaluate_repl(
};
line_editor = line_editor.with_history(history);
};
perf("setup history", start_time, file!(), line!(), column!());
perf(
"setup history",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
let sys = sysinfo::System::new();
@ -136,6 +152,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
if let Some(s) = prerun_command {
@ -145,6 +162,7 @@ pub fn evaluate_repl(
s.item.as_bytes(),
&format!("entry #{entry_num}"),
PipelineData::empty(),
false,
);
engine_state.merge_env(stack, get_guaranteed_cwd(engine_state, stack))?;
}
@ -160,21 +178,42 @@ pub fn evaluate_repl(
if let Err(err) = engine_state.merge_env(stack, cwd) {
report_error_new(engine_state, &err);
}
perf("merge env", start_time, file!(), line!(), column!());
perf(
"merge env",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
//Reset the ctrl-c handler
if let Some(ctrlc) = &mut engine_state.ctrlc {
ctrlc.store(false, Ordering::SeqCst);
}
perf("reset ctrlc", start_time, file!(), line!(), column!());
perf(
"reset ctrlc",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
// Reset the SIGQUIT handler
if let Some(sig_quit) = engine_state.get_sig_quit() {
sig_quit.store(false, Ordering::SeqCst);
}
perf("reset sig_quit", start_time, file!(), line!(), column!());
perf(
"reset sig_quit",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
let config = engine_state.get_config();
@ -197,6 +236,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
@ -217,7 +257,14 @@ pub fn evaluate_repl(
.with_partial_completions(config.partial_completions)
.with_ansi_colors(config.use_ansi_coloring)
.with_cursor_config(cursor_config);
perf("reedline builder", start_time, file!(), line!(), column!());
perf(
"reedline builder",
start_time,
file!(),
line!(),
column!(),
use_color,
);
let style_computer = StyleComputer::from_config(engine_state, stack);
@ -237,6 +284,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
@ -245,7 +293,14 @@ pub fn evaluate_repl(
report_error(&working_set, &e);
Reedline::create()
});
perf("reedline menus", start_time, file!(), line!(), column!());
perf(
"reedline menus",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
let buffer_editor = if !config.buffer_editor.is_empty() {
@ -274,6 +329,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
@ -282,7 +338,14 @@ pub fn evaluate_repl(
warn!("Failed to sync history: {}", e);
}
}
perf("sync_history", start_time, file!(), line!(), column!());
perf(
"sync_history",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
// Changing the line editor based on the found keybindings
@ -306,7 +369,14 @@ pub fn evaluate_repl(
line_editor
}
};
perf("keybindings", start_time, file!(), line!(), column!());
perf(
"keybindings",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
// Right before we start our prompt and take input from the user,
@ -316,7 +386,14 @@ pub fn evaluate_repl(
report_error_new(engine_state, &err);
}
}
perf("pre-prompt hook", start_time, file!(), line!(), column!());
perf(
"pre-prompt hook",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
// Next, check all the environment variables they ask for
@ -327,12 +404,26 @@ pub fn evaluate_repl(
{
report_error_new(engine_state, &error)
}
perf("env-change hook", start_time, file!(), line!(), column!());
perf(
"env-change hook",
start_time,
file!(),
line!(),
column!(),
use_color,
);
start_time = std::time::Instant::now();
let config = engine_state.get_config();
let prompt = prompt_update::update_prompt(config, engine_state, stack, &mut nu_prompt);
perf("update_prompt", start_time, file!(), line!(), column!());
perf(
"update_prompt",
start_time,
file!(),
line!(),
column!(),
use_color,
);
entry_num += 1;
@ -472,6 +563,7 @@ pub fn evaluate_repl(
s.as_bytes(),
&format!("entry #{entry_num}"),
PipelineData::empty(),
false,
);
}
let cmd_duration = start_time.elapsed();
@ -585,6 +677,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
perf(
@ -593,6 +686,7 @@ pub fn evaluate_repl(
file!(),
line!(),
column!(),
use_color,
);
}

View File

@ -1,5 +1,5 @@
use crate::repl::eval_hook;
use nu_engine::eval_block;
use nu_engine::{eval_block, eval_block_with_early_return};
use nu_parser::{escape_quote_string, lex, parse, unescape_unquote_string, Token, TokenContents};
use nu_protocol::engine::StateWorkingSet;
use nu_protocol::CliError;
@ -203,6 +203,7 @@ pub fn eval_source(
source: &[u8],
fname: &str,
input: PipelineData,
allow_return: bool,
) -> bool {
let start_time = std::time::Instant::now();
@ -230,7 +231,13 @@ pub fn eval_source(
return false;
}
match eval_block(engine_state, stack, &block, input, false, false) {
let b = if allow_return {
eval_block_with_early_return(engine_state, stack, &block, input, false, false)
} else {
eval_block(engine_state, stack, &block, input, false, false)
};
match b {
Ok(pipeline_data) => {
let config = engine_state.get_config();
let result;
@ -290,6 +297,7 @@ pub fn eval_source(
file!(),
line!(),
column!(),
engine_state.get_config().use_ansi_coloring,
);
true

View File

@ -574,9 +574,12 @@ fn variables_completions() {
// Test completions for $env
let suggestions = completer.complete("$env.", 5);
assert_eq!(2, suggestions.len());
assert_eq!(3, suggestions.len());
let expected: Vec<String> = vec!["PWD".into(), "TEST".into()];
#[cfg(windows)]
let expected: Vec<String> = vec!["PWD".into(), "Path".into(), "TEST".into()];
#[cfg(not(windows))]
let expected: Vec<String> = vec!["PATH".into(), "PWD".into(), "TEST".into()];
// Match results
match_suggestions(expected, suggestions);
@ -816,8 +819,9 @@ fn extern_complete_flags(mut extern_completer: NuCompleter) {
match_suggestions(expected, suggestions);
}
#[ignore = "was reverted, still needs fixing"]
#[rstest]
fn alias_offset_bug_7748() {
fn alias_offset_bug_7648() {
let (dir, _, mut engine, mut stack) = new_engine();
// Create an alias
@ -826,15 +830,15 @@ fn alias_offset_bug_7748() {
let mut completer = NuCompleter::new(std::sync::Arc::new(engine), stack);
// Issue #7748
// Issue #7648
// Nushell crashes when an alias name is shorter than the alias command
// and the alias command is a external command
// This happens because of offset is not correct.
// This crashes before PR #7779
let _suggestions = completer.complete("e", 1);
//println!(" --------- suggestions: {:?}", suggestions);
}
#[ignore = "was reverted, still needs fixing"]
#[rstest]
fn alias_offset_bug_7754() {
let (dir, _, mut engine, mut stack) = new_engine();
@ -850,6 +854,14 @@ fn alias_offset_bug_7754() {
// and the alias command contains pipes.
// This crashes before PR #7756
let _suggestions = completer.complete("ll -a | c", 9);
//println!(" --------- suggestions: {:?}", suggestions);
}
#[test]
fn get_path_env_var_8003() {
// Create a new engine
let (_, _, engine, _) = new_engine();
// Get the path env var in a platform agnostic way
let the_path = engine.get_path_env_var();
// Make sure it's not empty
assert!(the_path.is_some());
}

View File

@ -43,6 +43,22 @@ pub fn new_engine() -> (PathBuf, String, EngineState, Stack) {
span: nu_protocol::Span::new(0, dir_str.len()),
},
);
#[cfg(windows)]
stack.add_env_var(
"Path".to_string(),
Value::String {
val: "c:\\some\\path;c:\\some\\other\\path".to_string(),
span: nu_protocol::Span::new(0, dir_str.len()),
},
);
#[cfg(not(windows))]
stack.add_env_var(
"PATH".to_string(),
Value::String {
val: "/some/path:/some/other/path".to_string(),
span: nu_protocol::Span::new(0, dir_str.len()),
},
);
// Merge environment into the permanent state
let merge_result = engine_state.merge_env(&mut stack, &dir);

View File

@ -5,18 +5,21 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-confi
edition = "2021"
license = "MIT"
name = "nu-color-config"
version = "0.75.0"
version = "0.76.0"
[lib]
bench = false
[dependencies]
serde = { version="1.0.123", features=["derive"] }
# used only for text_style Alignments
tabled = { version = "0.10.0", features = ["color"], default-features = false }
nu-protocol = { path = "../nu-protocol", version = "0.75.0" }
nu-protocol = { path = "../nu-protocol", version = "0.76.0" }
nu-ansi-term = "0.46.0"
nu-utils = { path = "../nu-utils", version = "0.75.0" }
nu-engine = { path = "../nu-engine", version = "0.75.0" }
nu-json = { path="../nu-json", version = "0.75.0" }
nu-utils = { path = "../nu-utils", version = "0.76.0" }
nu-engine = { path = "../nu-engine", version = "0.76.0" }
nu-json = { path="../nu-json", version = "0.76.0" }
[dev-dependencies]
nu-test-support = { path="../nu-test-support", version = "0.75.0" }
nu-test-support = { path="../nu-test-support", version = "0.76.0" }

View File

@ -1,40 +1,44 @@
[package]
authors = ["The Nushell Project Developers"]
build = "build.rs"
description = "Nushell's built-in commands"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command"
edition = "2021"
license = "MIT"
name = "nu-command"
version = "0.75.0"
build = "build.rs"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command"
version = "0.76.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
bench = false
[dependencies]
nu-color-config = { path = "../nu-color-config", version = "0.75.0" }
nu-engine = { path = "../nu-engine", version = "0.75.0" }
nu-glob = { path = "../nu-glob", version = "0.75.0" }
nu-json = { path = "../nu-json", version = "0.75.0" }
nu-parser = { path = "../nu-parser", version = "0.75.0" }
nu-path = { path = "../nu-path", version = "0.75.0" }
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.75.0" }
nu-protocol = { path = "../nu-protocol", version = "0.75.0" }
nu-system = { path = "../nu-system", version = "0.75.0" }
nu-table = { path = "../nu-table", version = "0.75.0" }
nu-term-grid = { path = "../nu-term-grid", version = "0.75.0" }
nu-utils = { path = "../nu-utils", version = "0.75.0" }
nu-explore = { path = "../nu-explore", version = "0.75.0" }
nu-ansi-term = "0.46.0"
nu-color-config = { path = "../nu-color-config", version = "0.76.0" }
nu-engine = { path = "../nu-engine", version = "0.76.0" }
nu-explore = { path = "../nu-explore", version = "0.76.0" }
nu-glob = { path = "../nu-glob", version = "0.76.0" }
nu-json = { path = "../nu-json", version = "0.76.0" }
nu-parser = { path = "../nu-parser", version = "0.76.0" }
nu-path = { path = "../nu-path", version = "0.76.0" }
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.76.0" }
nu-protocol = { path = "../nu-protocol", version = "0.76.0" }
nu-system = { path = "../nu-system", version = "0.76.0" }
nu-table = { path = "../nu-table", version = "0.76.0" }
nu-term-grid = { path = "../nu-term-grid", version = "0.76.0" }
nu-utils = { path = "../nu-utils", version = "0.76.0" }
num-format = { version = "0.4.3" }
# Potential dependencies for extras
Inflector = "0.11"
alphanumeric-sort = "1.4.4"
atty = "0.2.14"
base64 = "0.21.0"
byteorder = "1.4.3"
bytesize = "1.1.0"
calamine = "0.19.1"
chrono = { version = "0.4.23", features = ["unstable-locales", "std"], default-features = false }
chrono = { version = "0.4.23", features = ["std", "unstable-locales"], default-features = false }
chrono-humanize = "0.2.1"
chrono-tz = "0.8.1"
crossterm = "0.24.0"
@ -42,17 +46,14 @@ csv = "1.1.6"
dialoguer = { default-features = false, version = "0.10.3" }
digest = { default-features = false, version = "0.10.0" }
dtparse = "1.2.0"
eml-parser = "0.1.0"
encoding_rs = "0.8.30"
fancy-regex = "0.11.0"
filesize = "0.2.0"
filetime = "0.2.15"
fs_extra = "1.2.0"
fs_extra = "1.3.0"
htmlescape = "0.3.1"
ical = "0.7.0"
indexmap = { version = "1.7", features = ["serde-1"] }
indicatif = "0.17.2"
Inflector = "0.11"
is-root = "0.1.2"
itertools = "0.10.0"
log = "0.4.14"
@ -72,46 +73,46 @@ rand = "0.8"
rayon = "1.6.1"
regex = "1.7.1"
reqwest = { version = "0.11", features = ["blocking", "json"] }
roxmltree = "0.17.0"
roxmltree = "0.18.0"
rust-embed = "6.3.0"
same-file = "1.0.6"
serde = { version = "1.0.123", features = ["derive"] }
serde_ini = "0.2.0"
serde_urlencoded = "0.7.0"
serde_yaml = "0.9.4"
sha2 = "0.10.0"
# Disable default features b/c the default features build Git (very slow to compile)
percent-encoding = "2.2.0"
reedline = { version = "0.16.0", features = ["bashisms", "sqlite"] }
rusqlite = { version = "0.28.0", features = ["bundled"], optional = true }
shadow-rs = { version = "0.20.0", default-features = false }
sysinfo = "0.27.7"
sqlparser = { version = "0.30.0", features = ["serde"], optional = true }
sysinfo = "0.28.0"
tabled = "0.10.0"
terminal_size = "0.2.1"
thiserror = "1.0.31"
titlecase = "2.0.0"
toml = "0.5.8"
unicode-segmentation = "1.8.0"
toml = "0.7.1"
unicode-segmentation = "1.10.0"
unicode-width = "0.1.10"
url = "2.2.1"
percent-encoding = "2.2.0"
uuid = { version = "1.2.2", features = ["v4"] }
which = { version = "4.3.0", optional = true }
reedline = { version = "0.15.0", features = ["bashisms", "sqlite"] }
wax = { version = "0.5.0" }
rusqlite = { version = "0.28.0", features = ["bundled"], optional = true }
sqlparser = { version = "0.30.0", features = ["serde"], optional = true }
which = { version = "4.4.0", optional = true }
print-positions = "0.6.1"
[target.'cfg(windows)'.dependencies]
winreg = "0.10.1"
winreg = "0.11.0"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
umask = "2.0.0"
users = "0.11.0"
libc = "0.2"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies.trash]
version = "3.0.1"
optional = true
version = "3.0.1"
[dependencies.polars]
version = "0.26.1"
optional = true
features = [
"arg_where",
"checked_arithmetic",
@ -120,9 +121,9 @@ features = [
"csv-file",
"cum_agg",
"default",
"dtype-categorical",
"dtype-datetime",
"dtype-struct",
"dtype-categorical",
"dynamic_groupby",
"ipc",
"is_in",
@ -139,27 +140,29 @@ features = [
"strings",
"to_dummies",
]
optional = true
version = "0.26.1"
[target.'cfg(windows)'.dependencies.windows]
version = "0.44.0"
features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_SystemServices"]
version = "0.44.0"
[features]
dataframe = ["num", "polars", "sqlparser"]
plugin = ["nu-parser/plugin"]
sqlite = ["rusqlite"] # TODO: given that rusqlite is included in reedline, should we just always include it?
trash-support = ["trash"]
which-support = ["which"]
plugin = ["nu-parser/plugin"]
dataframe = ["polars", "num", "sqlparser"]
sqlite = ["rusqlite"] # TODO: given that rusqlite is included in reedline, should we just always include it?
[build-dependencies]
shadow-rs = { version = "0.20.0", default-features = false }
[dev-dependencies]
nu-test-support = { path = "../nu-test-support", version = "0.75.0" }
nu-test-support = { path = "../nu-test-support", version = "0.76.0" }
hamcrest2 = "0.3.0"
dirs-next = "2.0.0"
proptest = "1.0.0"
hamcrest2 = "0.3.0"
proptest = "1.1.0"
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"
rstest = { version = "0.15.0", default-features = false }
rstest = { version = "0.16.0", default-features = false }

View File

@ -39,7 +39,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let target: i64 = call.req(engine_state, stack, 0)?;

View File

@ -2,7 +2,7 @@ use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, IntoPipelineData, PipelineData, Signature, Type, Value,
Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
};
#[derive(Clone)]
@ -33,7 +33,7 @@ impl Command for Bits {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&Bits.signature(),

View File

@ -46,7 +46,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let signed = call.has_flag("signed");
let number_bytes: Option<Spanned<String>> =

View File

@ -39,7 +39,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let target: i64 = call.req(engine_state, stack, 0)?;

View File

@ -49,7 +49,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let bits: usize = call.req(engine_state, stack, 0)?;
let signed = call.has_flag("signed");

View File

@ -49,7 +49,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let bits: usize = call.req(engine_state, stack, 0)?;
let signed = call.has_flag("signed");

View File

@ -49,7 +49,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let bits: usize = call.req(engine_state, stack, 0)?;
let signed = call.has_flag("signed");

View File

@ -49,7 +49,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let bits: usize = call.req(engine_state, stack, 0)?;
let signed = call.has_flag("signed");

View File

@ -39,7 +39,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let target: i64 = call.req(engine_state, stack, 0)?;
// This doesn't match explicit nulls

View File

@ -46,7 +46,7 @@ impl Command for BytesBuild {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let mut output = vec![];
for expr in call.positional_iter() {
let val = eval_expression(engine_state, stack, expr)?;

View File

@ -2,7 +2,7 @@ use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, IntoPipelineData, PipelineData, Signature, Type, Value,
Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
};
#[derive(Clone)]
@ -33,7 +33,7 @@ impl Command for Bytes {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&Bytes.signature(),

View File

@ -0,0 +1,269 @@
use crate::input_handler::{operate, CmdArgument};
use nu_engine::CallExt;
use nu_protocol::{
ast::{Call, CellPath},
engine::{Command, EngineState, Stack},
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
use print_positions::print_positions;
#[derive(Clone)]
pub struct Fill;
struct Arguments {
width: usize,
alignment: FillAlignment,
character: String,
cell_paths: Option<Vec<CellPath>>,
}
impl CmdArgument for Arguments {
fn take_cell_paths(&mut self) -> Option<Vec<CellPath>> {
self.cell_paths.take()
}
}
#[derive(Clone, Copy)]
enum FillAlignment {
Left,
Right,
Middle,
MiddleRight,
}
impl Command for Fill {
fn name(&self) -> &str {
"fill"
}
fn usage(&self) -> &str {
"Fill and Align"
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("fill")
.input_output_types(vec![
(Type::Int, Type::String),
(Type::Float, Type::String),
(Type::String, Type::String),
(Type::Filesize, Type::String),
])
.vectorizes_over_list(true)
.named(
"width",
SyntaxShape::Int,
"The width of the output. Defaults to 1",
Some('w'),
)
.named(
"alignment",
SyntaxShape::String,
"The alignment of the output. Defaults to Left (Left(l), Right(r), Center(c/m), MiddleRight(cr/mr))",
Some('a'),
)
.named(
"character",
SyntaxShape::String,
"The character to fill with. Defaults to ' ' (space)",
Some('c'),
)
.category(Category::Conversions)
}
fn search_terms(&self) -> Vec<&str> {
vec!["display", "render", "format", "pad", "align"]
}
fn examples(&self) -> Vec<Example> {
vec![
Example {
description:
"Fill a string on the left side to a width of 15 with the character '─'",
example: "'nushell' | fill -a l -c '─' -w 15",
result: Some(Value::String {
val: "nushell────────".into(),
span: Span::test_data(),
}),
},
Example {
description:
"Fill a string on the right side to a width of 15 with the character '─'",
example: "'nushell' | fill -a r -c '─' -w 15",
result: Some(Value::String {
val: "────────nushell".into(),
span: Span::test_data(),
}),
},
Example {
description: "Fill a string on both sides to a width of 15 with the character '─'",
example: "'nushell' | fill -a m -c '─' -w 15",
result: Some(Value::String {
val: "────nushell────".into(),
span: Span::test_data(),
}),
},
Example {
description:
"Fill a number on the left side to a width of 5 with the character '0'",
example: "1 | fill --alignment right --character 0 --width 5",
result: Some(Value::String {
val: "00001".into(),
span: Span::test_data(),
}),
},
Example {
description: "Fill a number on both sides to a width of 5 with the character '0'",
example: "1.1 | fill --alignment center --character 0 --width 5",
result: Some(Value::String {
val: "01.10".into(),
span: Span::test_data(),
}),
},
Example {
description:
"Fill a filesize on the left side to a width of 5 with the character '0'",
example: "1kib | fill --alignment middle --character 0 --width 10",
result: Some(Value::String {
val: "0001024000".into(),
span: Span::test_data(),
}),
},
]
}
fn run(
&self,
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
fill(engine_state, stack, call, input)
}
}
fn fill(
engine_state: &EngineState,
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
let width_arg: Option<usize> = call.get_flag(engine_state, stack, "width")?;
let alignment_arg: Option<String> = call.get_flag(engine_state, stack, "alignment")?;
let character_arg: Option<String> = call.get_flag(engine_state, stack, "character")?;
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths);
let alignment = if let Some(arg) = alignment_arg {
match arg.to_lowercase().as_str() {
"l" | "left" => FillAlignment::Left,
"r" | "right" => FillAlignment::Right,
"c" | "center" | "m" | "middle" => FillAlignment::Middle,
"cr" | "centerright" | "mr" | "middleright" => FillAlignment::MiddleRight,
_ => FillAlignment::Left,
}
} else {
FillAlignment::Left
};
let width = if let Some(arg) = width_arg { arg } else { 1 };
let character = if let Some(arg) = character_arg {
arg
} else {
" ".to_string()
};
let arg = Arguments {
width,
alignment,
character,
cell_paths,
};
operate(action, arg, input, call.head, engine_state.ctrlc.clone())
}
fn action(input: &Value, args: &Arguments, span: Span) -> Value {
match input {
Value::Int { val, .. } => fill_int(*val, args, span),
Value::Filesize { val, .. } => fill_int(*val, args, span),
Value::Float { val, .. } => fill_float(*val, args, span),
Value::String { val, .. } => fill_string(val, args, span),
// Propagate errors by explicitly matching them before the final case.
Value::Error { .. } => input.clone(),
other => Value::Error {
error: ShellError::OnlySupportsThisInputType(
"int, filesize, float, string".into(),
other.get_type().to_string(),
span,
// This line requires the Value::Error match above.
other.expect_span(),
),
},
}
}
fn fill_float(num: f64, args: &Arguments, span: Span) -> Value {
let s = num.to_string();
let out_str = pad(&s, args.width, &args.character, args.alignment, false);
Value::String { val: out_str, span }
}
fn fill_int(num: i64, args: &Arguments, span: Span) -> Value {
let s = num.to_string();
let out_str = pad(&s, args.width, &args.character, args.alignment, false);
Value::String { val: out_str, span }
}
fn fill_string(s: &str, args: &Arguments, span: Span) -> Value {
let out_str = pad(s, args.width, &args.character, args.alignment, false);
Value::String { val: out_str, span }
}
fn pad(s: &str, width: usize, pad_char: &str, alignment: FillAlignment, truncate: bool) -> String {
// Attribution: Most of this function was taken from https://github.com/ogham/rust-pad and tweaked. Thank you!
// Use width instead of len for graphical display
let cols = print_positions(s).count();
if cols >= width {
if truncate {
return s[..width].to_string();
} else {
return s.to_string();
}
}
let diff = width - cols;
let (left_pad, right_pad) = match alignment {
FillAlignment::Left => (0, diff),
FillAlignment::Right => (diff, 0),
FillAlignment::Middle => (diff / 2, diff - diff / 2),
FillAlignment::MiddleRight => (diff - diff / 2, diff / 2),
};
let mut new_str = String::new();
for _ in 0..left_pad {
new_str.push_str(pad_char)
}
new_str.push_str(s);
for _ in 0..right_pad {
new_str.push_str(pad_char)
}
new_str
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_examples() {
use crate::test_examples;
test_examples(Fill {})
}
}

View File

@ -64,7 +64,7 @@ impl Command for Fmt {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
fmt(engine_state, stack, call, input)
}
}
@ -74,7 +74,7 @@ fn fmt(
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
let args = CellPathOnlyArgs::from(cell_paths);
operate(action, args, input, call.head, engine_state.ctrlc.clone())

View File

@ -49,7 +49,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
into_binary(engine_state, stack, call, input)
}
@ -109,7 +109,7 @@ fn into_binary(
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;

View File

@ -45,7 +45,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
into_bool(engine_state, stack, call, input)
}

View File

@ -2,7 +2,7 @@ use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, IntoPipelineData, PipelineData, Signature, Type, Value,
Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
};
#[derive(Clone)]
@ -33,7 +33,7 @@ impl Command for Into {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&Into.signature(),

View File

@ -280,13 +280,13 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
Zone::East(i) => match FixedOffset::east_opt((*i as i32) * HOUR) {
Some(eastoffset) => match_datetime!(eastoffset.timestamp_opt(ts, 0)),
None => Value::Error {
error: ShellError::DatetimeParseError(*span),
error: ShellError::DatetimeParseError(input.debug_value(), *span),
},
},
Zone::West(i) => match FixedOffset::west_opt((*i as i32) * HOUR) {
Some(westoffset) => match_datetime!(westoffset.timestamp_opt(ts, 0)),
None => Value::Error {
error: ShellError::DatetimeParseError(*span),
error: ShellError::DatetimeParseError(input.debug_value(), *span),
},
},
Zone::Error => Value::Error {

View File

@ -41,7 +41,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
let args = CellPathOnlyArgs::from(cell_paths);
operate(action, args, input, call.head, engine_state.ctrlc.clone())

View File

@ -56,7 +56,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
into_duration(engine_state, stack, call, input)
}

View File

@ -44,7 +44,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cell_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
let args = CellPathOnlyArgs::from(cell_paths);
operate(action, args, input, call.head, engine_state.ctrlc.clone())

View File

@ -62,7 +62,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cell_paths = call.rest(engine_state, stack, 0)?;
let cell_paths = (!cell_paths.is_empty()).then_some(cell_paths);

View File

@ -40,7 +40,7 @@ impl Command for SubCommand {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
into_record(engine_state, call, input)
}

View File

@ -70,7 +70,7 @@ impl Command for SubCommand {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
string_helper(engine_state, stack, call, input)
}
@ -148,7 +148,7 @@ fn string_helper(
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, ShellError> {
) -> Result<PipelineData, ShellError> {
let decimals = call.has_flag("decimals");
let head = call.head;
let decimals_value: Option<i64> = call.get_flag(engine_state, stack, "decimals")?;

View File

@ -1,5 +1,7 @@
mod fill;
mod fmt;
pub(crate) mod into;
pub use fill::Fill;
pub use fmt::Fmt;
pub use into::*;

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct Alias;
@ -45,7 +47,7 @@ impl Command for Alias {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -35,7 +35,7 @@ impl Command for Break {
_stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Err(ShellError::Break(call.head))
}

View File

@ -46,7 +46,7 @@ impl Command for Const {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let var_id = call
.positional_nth(0)
.expect("checked through parser")

View File

@ -35,7 +35,7 @@ impl Command for Continue {
_stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Err(ShellError::Continue(call.head))
}

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct Def;
@ -38,7 +40,7 @@ impl Command for Def {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct DefEnv;
@ -26,32 +28,7 @@ impl Command for DefEnv {
fn extra_usage(&self) -> &str {
r#"This command is a parser keyword. For details, check:
https://www.nushell.sh/book/thinking_in_nu.html
=== EXTRA NOTE ===
All blocks are scoped, including variable definition and environment variable changes.
Because of this, the following doesn't work:
def-env cd_with_fallback [arg = ""] {
let fall_back_path = "/tmp"
if $arg != "" {
cd $arg
} else {
cd $fall_back_path
}
}
Instead, you have to use cd in the top level scope:
def-env cd_with_fallback [arg = ""] {
let fall_back_path = "/tmp"
let path = if $arg != "" {
$arg
} else {
$fall_back_path
}
cd $path
}"#
"#
}
fn is_parser_keyword(&self) -> bool {
@ -64,7 +41,7 @@ def-env cd_with_fallback [arg = ""] {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -215,17 +215,35 @@ impl Command for Do {
span,
metadata,
trim_end_newline,
}) if ignore_program_errors => Ok(PipelineData::ExternalStream {
stdout,
stderr,
exit_code: None,
span,
metadata,
trim_end_newline,
}),
}) if ignore_program_errors && !call.redirect_stdout => {
Ok(PipelineData::ExternalStream {
stdout,
stderr,
exit_code: None,
span,
metadata,
trim_end_newline,
})
}
Ok(PipelineData::Value(Value::Error { .. }, ..)) | Err(_) if ignore_shell_errors => {
Ok(PipelineData::empty())
}
Ok(PipelineData::ListStream(ls, metadata)) if ignore_shell_errors => {
// check if there is a `Value::Error` in given list stream first.
let mut values = vec![];
let ctrlc = ls.ctrlc.clone();
for v in ls {
if let Value::Error { .. } = v {
values.push(Value::nothing(call.head));
} else {
values.push(v)
}
}
Ok(PipelineData::ListStream(
ListStream::from_stream(values.into_iter(), ctrlc),
metadata,
))
}
r => r,
}
}

View File

@ -39,7 +39,7 @@ impl Command for ErrorMake {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let span = call.head;
let arg: Value = call.req(engine_state, stack, 0)?;
let unspanned = call.has_flag("unspanned");

View File

@ -2,7 +2,7 @@ use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value,
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
};
#[derive(Clone)]
@ -38,7 +38,7 @@ impl Command for ExportCommand {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&ExportCommand.signature(),

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct ExportAlias;
@ -41,7 +41,7 @@ impl Command for ExportAlias {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct ExportDef;
@ -38,7 +40,7 @@ impl Command for ExportDef {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct ExportDefEnv;
@ -64,7 +66,7 @@ export def-env cd_with_fallback [arg = ""] {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct ExportExtern;
@ -37,7 +37,7 @@ impl Command for ExportExtern {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct ExportUse;
@ -41,7 +43,7 @@ impl Command for ExportUse {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct Extern;
@ -37,7 +37,7 @@ impl Command for Extern {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -34,7 +34,7 @@ impl Command for For {
.required("block", SyntaxShape::Block, "the block to run")
.switch(
"numbered",
"returned a numbered item ($it.index and $it.item)",
"return a numbered item ($it.index and $it.item)",
Some('n'),
)
.creates_scope()
@ -56,7 +56,7 @@ impl Command for For {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let var_id = call
.positional_nth(0)

View File

@ -86,15 +86,15 @@ You can also learn more at https://www.nushell.sh/book/"#;
} else if find.is_some() {
help_commands(engine_state, stack, call)
} else {
let result = help_commands(engine_state, stack, call);
let result = help_aliases(engine_state, stack, call);
let result = if let Err(ShellError::CommandNotFound(_)) = result {
help_aliases(engine_state, stack, call)
let result = if let Err(ShellError::AliasNotFound(_)) = result {
help_commands(engine_state, stack, call)
} else {
result
};
let result = if let Err(ShellError::AliasNotFound(_)) = result {
let result = if let Err(ShellError::CommandNotFound(_)) = result {
help_modules(engine_state, stack, call)
} else {
result

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct Hide;
@ -43,7 +43,7 @@ This command is a parser keyword. For details, check:
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -40,12 +40,12 @@ impl Command for HideEnv {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let env_var_names: Vec<Spanned<String>> = call.rest(engine_state, stack, 0)?;
let ignore_errors = call.has_flag("ignore-errors");
for name in env_var_names {
if stack.remove_env_var(engine_state, &name.item).is_none() && !ignore_errors {
if !stack.remove_env_var(engine_state, &name.item) && !ignore_errors {
let all_names: Vec<String> = stack
.get_env_var_names(engine_state)
.iter()

View File

@ -55,7 +55,7 @@ impl Command for If {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cond = call.positional_nth(0).expect("checked through parser");
let then_block: Block = call.req(engine_state, stack, 1)?;
let else_case = call.positional_nth(2);

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, Span, Type, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value};
#[derive(Clone)]
pub struct Ignore;
@ -30,7 +30,7 @@ impl Command for Ignore {
_stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
input.into_value(call.head);
Ok(PipelineData::empty())
}

View File

@ -1,7 +1,7 @@
use nu_engine::eval_expression_with_input;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct Let;
@ -47,7 +47,7 @@ impl Command for Let {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let var_id = call
.positional_nth(0)
.expect("checked through parser")

View File

@ -40,7 +40,7 @@ impl Command for Loop {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let block: Block = call.req(engine_state, stack, 0)?;
loop {

View File

@ -1,10 +1,8 @@
mod alias;
mod ast;
mod break_;
mod commandline;
mod const_;
mod continue_;
mod debug;
mod def;
mod def_env;
mod describe;
@ -30,7 +28,6 @@ mod if_;
mod ignore;
mod let_;
mod loop_;
mod metadata;
mod module;
mod mut_;
pub(crate) mod overlay;
@ -41,12 +38,10 @@ mod version;
mod while_;
pub use alias::Alias;
pub use ast::Ast;
pub use break_::Break;
pub use commandline::Commandline;
pub use const_::Const;
pub use continue_::Continue;
pub use debug::Debug;
pub use def::Def;
pub use def_env::DefEnv;
pub use describe::Describe;
@ -72,7 +67,6 @@ pub use if_::If;
pub use ignore::Ignore;
pub use let_::Let;
pub use loop_::Loop;
pub use metadata::Metadata;
pub use module::Module;
pub use mut_::Mut;
pub use overlay::*;

View File

@ -1,6 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct Module;
@ -37,7 +39,7 @@ impl Command for Module {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -1,7 +1,7 @@
use nu_engine::eval_expression_with_input;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct Mut;
@ -47,7 +47,7 @@ impl Command for Mut {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let var_id = call
.positional_nth(0)
.expect("checked through parser")

View File

@ -2,7 +2,7 @@ use nu_engine::get_full_help;
use nu_protocol::{
ast::Call,
engine::{Command, EngineState, Stack},
Category, IntoPipelineData, PipelineData, Signature, Type, Value,
Category, IntoPipelineData, PipelineData, ShellError, Signature, Type, Value,
};
#[derive(Clone)]
@ -26,7 +26,7 @@ impl Command for Overlay {
fn extra_usage(&self) -> &str {
r#"This command is a parser keyword. For details, check:
https://www.nushell.sh/book/thinking_in_nu.html
You must use one of the following subcommands. Using this command as-is will only produce this help message."#
}
@ -40,7 +40,7 @@ impl Command for Overlay {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(Value::String {
val: get_full_help(
&Overlay.signature(),

View File

@ -50,7 +50,7 @@ impl Command for OverlayHide {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let overlay_name: Spanned<String> = if let Some(name) = call.opt(engine_state, stack, 0)? {
name
} else {

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Type};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)]
pub struct Register;
@ -51,7 +51,7 @@ impl Command for Register {
_stack: &mut Stack,
_call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
Ok(PipelineData::empty())
}

View File

@ -39,7 +39,7 @@ impl Command for Return {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let return_value: Option<Value> = call.opt(engine_state, stack, 0)?;
if let Some(value) = return_value {
Err(ShellError::Return(call.head, Box::new(value)))

View File

@ -2,7 +2,8 @@ use nu_engine::{eval_block, CallExt};
use nu_protocol::ast::Call;
use nu_protocol::engine::{Block, Closure, Command, EngineState, Stack};
use nu_protocol::{
Category, Example, IntoPipelineData, PipelineData, Signature, SyntaxShape, Type, Value,
Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Type,
Value,
};
#[derive(Clone)]
@ -47,7 +48,7 @@ impl Command for Try {
stack: &mut Stack,
call: &Call,
input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let try_block: Block = call.req(engine_state, stack, 0)?;
let catch_block: Option<Closure> = call.opt(engine_state, stack, 1)?;

View File

@ -45,7 +45,7 @@ impl Command for While {
stack: &mut Stack,
call: &Call,
_input: PipelineData,
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
) -> Result<PipelineData, ShellError> {
let cond = call.positional_nth(0).expect("checked through parser");
let block: Block = call.req(engine_state, stack, 1)?;

View File

@ -12,7 +12,7 @@ pub struct AppendDF;
impl Command for AppendDF {
fn name(&self) -> &str {
"append"
"dfr append"
}
fn usage(&self) -> &str {
@ -32,8 +32,8 @@ impl Command for AppendDF {
vec![
Example {
description: "Appends a dataframe as new columns",
example: r#"let a = ([[a b]; [1 2] [3 4]] | into df);
$a | append $a"#,
example: r#"let a = ([[a b]; [1 2] [3 4]] | dfr into-df);
$a | dfr append $a"#,
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(
@ -59,8 +59,8 @@ impl Command for AppendDF {
},
Example {
description: "Appends a dataframe merging at the end of columns",
example: r#"let a = ([[a b]; [1 2] [3 4]] | into df);
$a | append $a --col"#,
example: r#"let a = ([[a b]; [1 2] [3 4]] | dfr into-df);
$a | dfr append $a --col"#,
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -10,7 +10,7 @@ pub struct ColumnsDF;
impl Command for ColumnsDF {
fn name(&self) -> &str {
"columns"
"dfr columns"
}
fn usage(&self) -> &str {
@ -27,7 +27,7 @@ impl Command for ColumnsDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Dataframe columns",
example: "[[a b]; [1 2] [3 4]] | into df | columns",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr columns",
result: Some(Value::List {
vals: vec![Value::test_string("a"), Value::test_string("b")],
span: Span::test_data(),

View File

@ -13,7 +13,7 @@ pub struct DropDF;
impl Command for DropDF {
fn name(&self) -> &str {
"drop"
"dfr drop"
}
fn usage(&self) -> &str {
@ -31,7 +31,7 @@ impl Command for DropDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "drop column a",
example: "[[a b]; [1 2] [3 4]] | into df | drop a",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr drop a",
result: Some(
NuDataFrame::try_from_columns(vec![Column::new(
"b".to_string(),

View File

@ -14,7 +14,7 @@ pub struct DropDuplicates;
impl Command for DropDuplicates {
fn name(&self) -> &str {
"drop-duplicates"
"dfr drop-duplicates"
}
fn usage(&self) -> &str {
@ -42,7 +42,7 @@ impl Command for DropDuplicates {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "drop duplicates",
example: "[[a b]; [1 2] [3 4] [1 2]] | into df | drop-duplicates",
example: "[[a b]; [1 2] [3 4] [1 2]] | dfr into-df | dfr drop-duplicates",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -13,7 +13,7 @@ pub struct DropNulls;
impl Command for DropNulls {
fn name(&self) -> &str {
"drop-nulls"
"dfr drop-nulls"
}
fn usage(&self) -> &str {
@ -36,10 +36,10 @@ impl Command for DropNulls {
vec![
Example {
description: "drop null values in dataframe",
example: r#"let df = ([[a b]; [1 2] [3 0] [1 2]] | into df);
example: r#"let df = ([[a b]; [1 2] [3 0] [1 2]] | dfr into-df);
let res = ($df.b / $df.b);
let a = ($df | with-column $res --name res);
$a | drop-nulls"#,
let a = ($df | dfr with-column $res --name res);
$a | dfr drop-nulls"#,
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(
@ -61,8 +61,8 @@ impl Command for DropNulls {
},
Example {
description: "drop null values in dataframe",
example: r#"let s = ([1 2 0 0 3 4] | into df);
($s / $s) | drop-nulls"#,
example: r#"let s = ([1 2 0 0 3 4] | dfr into-df);
($s / $s) | dfr drop-nulls"#,
result: Some(
NuDataFrame::try_from_columns(vec![Column::new(
"div_0_0".to_string(),

View File

@ -10,7 +10,7 @@ pub struct DataTypes;
impl Command for DataTypes {
fn name(&self) -> &str {
"dtypes"
"dfr dtypes"
}
fn usage(&self) -> &str {
@ -27,7 +27,7 @@ impl Command for DataTypes {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Dataframe dtypes",
example: "[[a b]; [1 2] [3 4]] | into df | dtypes",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr dtypes",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -11,7 +11,7 @@ pub struct Dummies;
impl Command for Dummies {
fn name(&self) -> &str {
"dummies"
"dfr dummies"
}
fn usage(&self) -> &str {
@ -29,7 +29,7 @@ impl Command for Dummies {
vec![
Example {
description: "Create new dataframe with dummy variables from a dataframe",
example: "[[a b]; [1 2] [3 4]] | into df | dummies",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr dummies",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(
@ -55,7 +55,7 @@ impl Command for Dummies {
},
Example {
description: "Create new dataframe with dummy variables from a series",
example: "[1 2 2 3 3] | into df | dummies",
example: "[1 2 2 3 3] | dfr into-df | dfr dummies",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -15,7 +15,7 @@ pub struct FilterWith;
impl Command for FilterWith {
fn name(&self) -> &str {
"filter-with"
"dfr filter-with"
}
fn usage(&self) -> &str {
@ -38,8 +38,8 @@ impl Command for FilterWith {
vec![
Example {
description: "Filter dataframe using a bool mask",
example: r#"let mask = ([true false] | into df);
[[a b]; [1 2] [3 4]] | into df | filter-with $mask"#,
example: r#"let mask = ([true false] | dfr into-df);
[[a b]; [1 2] [3 4]] | dfr into-df | dfr filter-with $mask"#,
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)]),
@ -51,7 +51,7 @@ impl Command for FilterWith {
},
Example {
description: "Filter dataframe using an expression",
example: "[[a b]; [1 2] [3 4]] | into df | filter-with ((col a) > 1)",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr filter-with ((dfr col a) > 1)",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(3)]),

View File

@ -11,7 +11,7 @@ pub struct FirstDF;
impl Command for FirstDF {
fn name(&self) -> &str {
"first"
"dfr first"
}
fn usage(&self) -> &str {
@ -34,7 +34,7 @@ impl Command for FirstDF {
vec![
Example {
description: "Return the first row of a dataframe",
example: "[[a b]; [1 2] [3 4]] | into df | first",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr first",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)]),
@ -46,7 +46,7 @@ impl Command for FirstDF {
},
Example {
description: "Return the first two rows of a dataframe",
example: "[[a b]; [1 2] [3 4]] | into df | first 2",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr first 2",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -14,7 +14,7 @@ pub struct GetDF;
impl Command for GetDF {
fn name(&self) -> &str {
"get"
"dfr get"
}
fn usage(&self) -> &str {
@ -32,7 +32,7 @@ impl Command for GetDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Returns the selected column",
example: "[[a b]; [1 2] [3 4]] | into df | get a",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr get a",
result: Some(
NuDataFrame::try_from_columns(vec![Column::new(
"a".to_string(),

View File

@ -11,7 +11,7 @@ pub struct LastDF;
impl Command for LastDF {
fn name(&self) -> &str {
"last"
"dfr last"
}
fn usage(&self) -> &str {
@ -29,7 +29,7 @@ impl Command for LastDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Create new dataframe with last rows",
example: "[[a b]; [1 2] [3 4]] | into df | last 1",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr last 1",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(3)]),

View File

@ -11,7 +11,7 @@ pub struct ListDF;
impl Command for ListDF {
fn name(&self) -> &str {
"ls-df"
"dfr ls"
}
fn usage(&self) -> &str {
@ -25,8 +25,8 @@ impl Command for ListDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Creates a new dataframe and shows it in the dataframe list",
example: r#"let test = ([[a b];[1 2] [3 4]] | into df);
ls-df"#,
example: r#"let test = ([[a b];[1 2] [3 4]] | dfr into-df);
ls"#,
result: None,
}]
}

View File

@ -15,7 +15,7 @@ pub struct MeltDF;
impl Command for MeltDF {
fn name(&self) -> &str {
"melt"
"dfr melt"
}
fn usage(&self) -> &str {
@ -57,7 +57,7 @@ impl Command for MeltDF {
vec![Example {
description: "melt dataframe",
example:
"[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | into df | melt -c [b c] -v [a d]",
"[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | dfr into-df | dfr melt -c [b c] -v [a d]",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -18,7 +18,7 @@ pub struct OpenDataFrame;
impl Command for OpenDataFrame {
fn name(&self) -> &str {
"open-df"
"dfr open"
}
fn usage(&self) -> &str {
@ -76,7 +76,7 @@ impl Command for OpenDataFrame {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Takes a file name and creates a dataframe",
example: "open test.csv",
example: "dfr open test.csv",
result: None,
}]
}

View File

@ -18,7 +18,7 @@ pub struct QueryDf;
impl Command for QueryDf {
fn name(&self) -> &str {
"query df"
"dfr query"
}
fn usage(&self) -> &str {
@ -40,7 +40,7 @@ impl Command for QueryDf {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Query dataframe using SQL",
example: "[[a b]; [1 2] [3 4]] | into df | query df 'select a from df'",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr query 'select a from df'",
result: Some(
NuDataFrame::try_from_columns(vec![Column::new(
"a".to_string(),

View File

@ -14,7 +14,7 @@ pub struct RenameDF;
impl Command for RenameDF {
fn name(&self) -> &str {
"rename"
"dfr rename"
}
fn usage(&self) -> &str {
@ -42,7 +42,7 @@ impl Command for RenameDF {
vec![
Example {
description: "Renames a series",
example: "[5 6 7 8] | into df | rename '0' new_name",
example: "[5 6 7 8] | dfr into-df | dfr rename '0' new_name",
result: Some(
NuDataFrame::try_from_columns(vec![Column::new(
"new_name".to_string(),
@ -59,7 +59,7 @@ impl Command for RenameDF {
},
Example {
description: "Renames a dataframe column",
example: "[[a b]; [1 2] [3 4]] | into df | rename a a_new",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr rename a a_new",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(
@ -77,7 +77,7 @@ impl Command for RenameDF {
},
Example {
description: "Renames two dataframe columns",
example: "[[a b]; [1 2] [3 4]] | into df | rename [a b] [a_new b_new]",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr rename [a b] [a_new b_new]",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

View File

@ -12,7 +12,7 @@ pub struct SampleDF;
impl Command for SampleDF {
fn name(&self) -> &str {
"sample"
"dfr sample"
}
fn usage(&self) -> &str {
@ -50,12 +50,12 @@ impl Command for SampleDF {
vec![
Example {
description: "Sample rows from dataframe",
example: "[[a b]; [1 2] [3 4]] | into df | sample -n 1",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr sample -n 1",
result: None, // No expected value because sampling is random
},
Example {
description: "Shows sample row using fraction and replace",
example: "[[a b]; [1 2] [3 4] [5 6]] | into df | sample -f 0.5 -e",
example: "[[a b]; [1 2] [3 4] [5 6]] | dfr into-df | dfr sample -f 0.5 -e",
result: None, // No expected value because sampling is random
},
]

View File

@ -13,7 +13,7 @@ pub struct ShapeDF;
impl Command for ShapeDF {
fn name(&self) -> &str {
"shape"
"dfr shape"
}
fn usage(&self) -> &str {
@ -30,7 +30,7 @@ impl Command for ShapeDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Shows row and column shape",
example: "[[a b]; [1 2] [3 4]] | into df | shape",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr shape",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new("rows".to_string(), vec![Value::test_int(2)]),

View File

@ -14,7 +14,7 @@ pub struct SliceDF;
impl Command for SliceDF {
fn name(&self) -> &str {
"slice"
"dfr slice"
}
fn usage(&self) -> &str {
@ -33,7 +33,7 @@ impl Command for SliceDF {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Create new dataframe from a slice of the rows",
example: "[[a b]; [1 2] [3 4]] | into df | slice 0 1",
example: "[[a b]; [1 2] [3 4]] | dfr into-df | dfr slice 0 1",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)]),

View File

@ -19,7 +19,7 @@ pub struct Summary;
impl Command for Summary {
fn name(&self) -> &str {
"summary"
"dfr summary"
}
fn usage(&self) -> &str {
@ -42,7 +42,7 @@ impl Command for Summary {
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "list dataframe descriptives",
example: "[[a b]; [1 1] [1 1]] | into df | summary",
example: "[[a b]; [1 1] [1 1]] | dfr into-df | dfr summary",
result: Some(
NuDataFrame::try_from_columns(vec![
Column::new(

Some files were not shown because too many files have changed in this diff Show More