Commit Graph

2202 Commits

Author SHA1 Message Date
Jérémy Audiger
66398fbf77
Factorize HTTP commands code (#8088)
# Description

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

# User-Facing Changes

Both commands do support the timeout option.

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

# Tests + Formatting

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

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

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

# After Submitting

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

So as I said they suppose to be there;

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

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

---------

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

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

# User-Facing Changes

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

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-16 13:33:25 +00:00
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
Darren Schroeder
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
Darren Schroeder
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
Michael Angerman
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
Darren Schroeder
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
WindSoilder
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
WindSoilder
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
dependabot[bot]
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
dependabot[bot]
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
dependabot[bot]
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
Ryan Devenney
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
Maxim Zhiburt
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
Stefan Holderbach
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
Jakub Žádník
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
Bob Hyman
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
Darren Schroeder
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
Jakub Žádník
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
Darren Schroeder
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
Darren Schroeder
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
Stefan Holderbach
cfd2cc4970
Minor clippy: inline format string (#8043)
# Description

Clippy from nightly being pedantic
2023-02-11 17:47:08 +00:00
Darren Schroeder
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
Darren Schroeder
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
Darren Schroeder
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
Reilly Wood
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
dependabot[bot]
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
Artemiy
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
Darren Schroeder
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
NitinL
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
pwygab
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
WindSoilder
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
Darren Schroeder
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
Maxim Zhiburt
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
Jérémy Audiger
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
Reilly Wood
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
Amirhossein Akhlaghpour
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
Darren Schroeder
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
Nitin Londhe
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
Jérémy Audiger
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
dependabot[bot]
b5561f35b9
Bump which from 4.3.0 to 4.4.0 (#7974) 2023-02-06 10:43:28 +00:00
Stefan Holderbach
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
Stefan Holderbach
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
dependabot[bot]
d50eb9b41b
Bump fs_extra from 1.2.0 to 1.3.0 (#7976) 2023-02-06 09:59:58 +00:00
Jakub Žádník
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
Amirhossein Akhlaghpour
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
Jérémy Audiger
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
Grzegorz Caban
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
Leon
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
Darren Schroeder
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
WindSoilder
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
Kornél Csernai
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
pwygab
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
Amirhossein Akhlaghpour
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
Darren Schroeder
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
Stefan Holderbach
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
Stefan Holderbach
17a265b197
Version bump for 0.75 release (#7902)
- [x] Are we ready for the release
- [x] Upgrade to upcoming `reedline 0.15`
2023-01-31 21:00:59 +01:00
Jakub Žádník
517ef7cde7
Remove deprecated where -b parameter (#7927) 2023-01-31 21:05:28 +02:00
Stefan Holderbach
ad14b763f9
Pin reedline to new 0.15 for release (#7918)
# Description

See release notes:

https://github.com/nushell/reedline/releases/tag/v0.15.0
2023-01-30 22:59:15 +01:00
WindSoilder
f74694d5a3
Let redirection keep exit code (#7848)
# Description

Fixes: #7828

We delegate to `save` command to finish redirection, then if it runs to
success, the relative exit code is set to 0. To fix it, in redirection
context, we take exit_code stream before sending it to `save` command,
than manually returns `PipelineData::ExternalStream` to make nushell set
relative code properly.

# 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-01-30 16:49:31 +01:00
Stefan Holderbach
1ea39abcff
Apply more recent/nightly clippy lints (#7916)
# Description

- Use inline format strings in dataframe code
- Fix manual `.is_ascii_digit()` check
- Remove unnecessary `.into_iter()` calls
2023-01-30 14:06:36 +01:00
Stefan Holderbach
7402589775
Bump trash to 3.0.1 (#7914)
# Description

Avoids duplication of `windows` crate and friends as it updates to the
most recent `windows 0.44` version.

# User-Facing Changes

None intended
2023-01-30 11:58:56 +01:00
dependabot[bot]
809416e3f0
Bump roxmltree from 0.16.0 to 0.17.0 (#7909) 2023-01-30 02:43:11 +00:00
dependabot[bot]
040d812343
Bump windows from 0.43.0 to 0.44.0 (#7911) 2023-01-30 02:17:18 +00:00
dependabot[bot]
72465e6724
Bump chrono-tz from 0.6.3 to 0.8.1 (#7907) 2023-01-30 01:38:39 +00:00
Stefan Holderbach
ab480856a5
Use variable names directly in the format strings (#7906)
# Description

Lint: `clippy::uninlined_format_args`

More readable in most situations.
(May be slightly confusing for modifier format strings
https://doc.rust-lang.org/std/fmt/index.html#formatting-parameters)

Alternative to #7865

# User-Facing Changes

None intended

# Tests + Formatting

(Ran `cargo +stable clippy --fix --workspace -- -A clippy::all -D
clippy::uninlined_format_args` to achieve this. Depends on Rust `1.67`)
2023-01-29 19:37:54 -06:00
JT
421bc828ef
Use clippy-recommended simplification (#7904)
# Description

Just a couple clippy-recommended simplifications.

# 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-01-29 23:31:35 +01:00
pwygab
8c7e2dbdf9
make parse -r columns return 0-indexed uncapitalised (#7897)
# Description

Fixes #7886.

```
/home/gabriel/CodingProjects/nushell〉'A|B|C' | parse -r '(\w)\|(\w)\|(\w)'                                                                                             01/29/2023 01:08:29 PM
╭───┬──────────┬──────────┬──────────╮
│ # │ capture0 │ capture1 │ capture2 │
├───┼──────────┼──────────┼──────────┤
│ 0 │ A        │ B        │ C        │
╰───┴──────────┴──────────┴──────────╯
```

# User-Facing Changes
Columns automatically named by `parse -r` are now 0-indexec and
uncapitalised.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-29 07:34:34 -06:00
WindSoilder
afb4209f10
make help commands search term don't generate $nothing (#7896)
# Description

Relative:
`https://github.com/nushell/nushell/pull/7889#issuecomment-1407503567`

Make `search_terms` return empty string rather than nothing, so some
other command can handle it better

# 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-01-28 18:57:26 -06:00
WindSoilder
1d8775d237
mention do in complete command's doc (#7884)
# Description

Closes: #7841

# User-Facing Changes

new complete doc:
```
Complete the external piped in, collecting outputs and exit code

To collect stderr messages and exit_code, external piped in need to wrapped with `do`

Usage:
  > complete

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

Signatures:
  <any> | complete -> <record>

Examples:
  Run the external completion
  > ^external arg1 | complete

  Run external completion, collects stderr and exit_code
  > do { ^external arg1 } | complete
```

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-28 16:42:05 -06:00
Hofer-Julian
8787ec9fe8
Add Github Actions workflow to check for typos (#7892)
- Add Github Actions workflow to check typos
- Fix existing typos
2023-01-29 10:22:56 +13:00
Reilly Wood
1f810cd26a
Re-enable some good tests, remove some bad tests (#7875)
I tackled some of the disabled `FIXME`/`#[ignore]` tests. Most were
straightforward to re-enable, and a few of them did not deserve to be
re-enabled.

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-01-28 14:56:47 -06:00
Reilly Wood
f4d7d19370
Name threads (#7879)
I noticed that [it's pretty easy to name threads in
Rust](https://doc.rust-lang.org/std/thread/#naming-threads). We might as
well do this; it's a nice quality of life improvement when you're
profiling something and the developers took the time to give threads
names.

Also added/cleaned up some comments while I was in the area.
2023-01-28 21:40:52 +01:00
WindSoilder
2a9226a55c
refactor: use input_handler::operate in ansi_strip command (#7888)
# Description

While investigating `do --ignore-errors` issue, just found that
`ansi_strip` command using a custom `operate` function(which is not
needed), this pr is just a refactor

# 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-01-28 08:11:21 -06:00
Doru
3d65fd7cc4
Expose filtering by file type in glob (#7834)
# Description

Add flags for filtering the output of `glob` by file type. I find myself
occasionally wanting to do this, and getting a file's
[file_type](https://docs.rs/wax/latest/wax/struct.WalkEntry.html#method.file_type)
is presumably fast to do as it doesn't have to go through the fallible
metadata method.

The design of the signature does concern me; it's not as readable as a
filter or "include" type list would be. They have to be filtered one by
one, which can be annoying if you only want files `-D -S`, or only want
folders `-F -S`, or only want symlinks `--butwhy?`. I considered
SyntaxShape::Keyword for this but I'll just defer to comments on this PR
if they pop up.

I'd also like to bring up performance since including these flags
technically incurs a `.filter` penalty on all glob calls, which could be
optimized out if we added a branch for the no-filters case. But in
reality I'd expect the file system to be the bottleneck and the flags to
be pretty branch predictor friendly, so eh

# User-Facing Changes
Three new flags when using `glob` and a slightly more cluttered help
page. No breaking changes, I hope.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-28 07:50:12 -06:00
JT
36ddbfdc85
Add 'number' command for enumeration (#7871)
# Description

This adds a `number` command that will enumerate the input, and add an
`index` and `item` record for each item. The `index` is the number of
the item in the input stream, and `item` is the original value of the
item.

```
> ls | number | get 14
╭───────┬────────────────────────────╮
│ index │ 14                         │
│       │ ╭──────────┬─────────────╮ │
│ item  │ │ name     │ crates      │ │
│       │ │ type     │ dir         │ │
│       │ │ size     │ 832 B       │ │
│       │ │ modified │ 2 weeks ago │ │
│       │ ╰──────────┴─────────────╯ │
╰───────┴────────────────────────────╯
```

# User-Facing Changes

This adds a `number` 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-01-28 06:45:57 +13:00
Reilly Wood
76292ef10c
Clean up cd.rs (#7876)
Some general cleanup of `cd.rs`; the permission checking code was a
little hard to follow. Reworded comments and variable names,
reorganized+renamed the module used for Unix file permissions.
2023-01-27 15:02:38 +01:00
Darren Schroeder
9d0e52b94d
with the release of rust 1.67, let's bump to 1.66.1 (#7866)
# Description

This PR bumps the required rust version to 1.66.1.

# 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-01-26 15:31:17 -06:00
Maxim Zhiburt
731f5f8523
nu-commands/table (table -e) Recognize limited space better (#7861)
fix #7858

Once again we here 😞 

~~I am thinking is there some files with not flat structure we could use
to test table -e?
I mean it is clear it was a while ago were we had to create at least
some tests.
Do you have anything in mind (or maybe commands which is consistent
across systems)?~~

Take care

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-01-26 14:06:17 -06:00
Alex Saveau
9d6d43ee55
Fix do swallowing all output when ignoring errors (#7859)
https://github.com/nushell/nushell/pull/7204#issuecomment-1404363845
2023-01-26 13:00:48 +01:00
WindSoilder
e1df8d14b4
improve doc about flatten (#7856)
# Description

Relative #7210 

Improve doc to clarify current behavior.

To flatten all nested levels, we can use the following custom
command(maybe making it into our lib):
```
def flatten_all_nested [input_table: any] {
    mut input = $input_table

    mut flattened = ($input | flatten --all)
    while $input != $flattened {
        $input = $flattened
        $flattened = ($input | flatten --all)
    }
    $flattened
}
```

# 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-01-25 10:10:30 -08:00
Artemiy
b9419e0f36
To csv fix (#7850)
# Description

Fixes #7800 . 
`to csv` and `to tsv` no longer:
- accept anything but records and tables as input,
- accept lists that are not tables,
- accept tables and records with values that are not primitives (other
lists, tables and records).

# User-Facing Changes

Using `to csv` and `to tsv` on any of inputs mentioned above will result
in `cant_convert` 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.

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-01-25 08:42:53 -06:00
Reilly Wood
2e44e4d33c
Fix the build after #7204 (#7857)
Fix the build after merging
https://github.com/nushell/nushell/pull/7204. It sat for a bit too long
and I should have rerun CI before merging it, my bad.
2023-01-24 22:12:15 -08:00
Alex Saveau
5cbaabeeab
Fix pipeline stall in do during capture and remove excessive redirections (#7204)
Currently, if you run `do -i { sudo apt upgrade }`, stdin gets swallowed
and doesn't let you respond yes/no to the upgrade question. This PR
fixes that, but runs into https://github.com/nushell/nushell/issues/7205
so the tests fail.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-01-25 00:24:38 -05:00
Hofer-Julian
41306aa7e0
Reduce again the number of match calls (#7815)
- Reduce the number of match calls (see commit messages)
- A few miscellaneous improvements
2023-01-24 12:23:42 +01:00
Kangaxx-0
0bb2e47c98
Incorrect parsing of unbalanced braces based on issue 6914 (#7621) 2023-01-24 10:05:46 +02:00
Darren Schroeder
ef660be285
print nushell startup time (#7831)
# Description

This PR shows the startup time and decreases the banner. This startup
time output can be disabled with the `show_banner: false` setting in the
config. This is the startup in debug mode.

![image](https://user-images.githubusercontent.com/343840/213955410-f319f8d4-1f96-47ae-8366-1c564a08d3e4.png)

On my mac in release mode
```
Startup Time: 368ms 429µs 83ns
```
On my mac without a config as `nu --config foo --env-config foo`
```
Startup Time: 11ms 663µs 791ns
```

I could really go either way on this. If people don't like this change,
we don't have to merge it.

# User-Facing Changes

Startup Time

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](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-01-23 12:57:40 -06:00
dependabot[bot]
4bac90a3b2
Bump rayon from 1.5.3 to 1.6.1 (#7836)
Bumps [rayon](https://github.com/rayon-rs/rayon) from 1.5.3 to 1.6.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/rayon-rs/rayon/blob/master/RELEASES.md">rayon's
changelog</a>.</em></p>
<blockquote>
<h1>Release rayon 1.6.1 (2022-12-09)</h1>
<ul>
<li>Simplified <code>par_bridge</code> to only pull one item at a time
from the iterator,
without batching. Threads that are waiting for iterator items will now
block
appropriately rather than spinning CPU. (Thanks <a
href="https://github.com/njaard"><code>@​njaard</code></a>!)</li>
<li>Added protection against recursion in <code>par_bridge</code>, so
iterators that also
invoke rayon will not cause mutex recursion deadlocks.</li>
</ul>
<h1>Release rayon-core 1.10.1 (2022-11-18)</h1>
<ul>
<li>Fixed a race condition with threads going to sleep while a broadcast
starts.</li>
</ul>
<h1>Release rayon 1.6.0 / rayon-core 1.10.0 (2022-11-18)</h1>
<ul>
<li>The minimum supported <code>rustc</code> is now 1.56.</li>
<li>The new <code>IndexedParallelIterator::fold_chunks</code> and
<code>fold_chunks_with</code> methods
work like <code>ParallelIterator::fold</code> and <code>fold_with</code>
with fixed-size chunks of
items. This may be useful for predictable batching performance, without
the
allocation overhead of
<code>IndexedParallelIterator::chunks</code>.</li>
<li>New &quot;broadcast&quot; methods run a given function on all
threads in the pool.
These run at a sort of reduced priority after each thread has exhausted
their
local work queue, but before they attempt work-stealing from other
threads.
<ul>
<li>The global <code>broadcast</code> function and
<code>ThreadPool::broadcast</code> method will
block until completion, returning a <code>Vec</code> of all return
values.</li>
<li>The global <code>spawn_broadcast</code> function and methods on
<code>ThreadPool</code>, <code>Scope</code>,
and <code>ScopeFifo</code> will run detached, without blocking the
current thread.</li>
</ul>
</li>
<li>Panicking methods now use <code>#[track_caller]</code> to report the
caller's location.</li>
<li>Fixed a truncated length in <code>vec::Drain</code> when given an
empty range.</li>
</ul>
<h2>Contributors</h2>
<p>Thanks to all of the contributors for this release!</p>
<ul>
<li><a href="https://github.com/cuviper"><code>@​cuviper</code></a></li>
<li><a
href="https://github.com/idanmuze"><code>@​idanmuze</code></a></li>
<li><a href="https://github.com/JoeyBF"><code>@​JoeyBF</code></a></li>
<li><a
href="https://github.com/JustForFun88"><code>@​JustForFun88</code></a></li>
<li><a
href="https://github.com/kianmeng"><code>@​kianmeng</code></a></li>
<li><a
href="https://github.com/kornelski"><code>@​kornelski</code></a></li>
<li><a
href="https://github.com/ritchie46"><code>@​ritchie46</code></a></li>
<li><a
href="https://github.com/ryanrussell"><code>@​ryanrussell</code></a></li>
<li><a
href="https://github.com/steffahn"><code>@​steffahn</code></a></li>
<li><a
href="https://github.com/TheIronBorn"><code>@​TheIronBorn</code></a></li>
<li><a
href="https://github.com/willcrozi"><code>@​willcrozi</code></a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="401678ee55"><code>401678e</code></a>
Merge <a
href="https://github-redirect.dependabot.com/rayon-rs/rayon/issues/709">#709</a></li>
<li><a
href="33e9843413"><code>33e9843</code></a>
Release rayon 1.2.1 / rayon-core 1.6.1</li>
<li><a
href="dd874ac5d4"><code>dd874ac</code></a>
Bump crate versions and dependencies</li>
<li><a
href="0c6338d267"><code>0c6338d</code></a>
Reduce Option complexity in demo cpu_time</li>
<li><a
href="be99e500bf"><code>be99e50</code></a>
cargo fmt</li>
<li><a
href="9b4d9798de"><code>9b4d979</code></a>
Avoid mem::uninitialized in the demo cpu_time</li>
<li><a
href="5a466434ab"><code>5a46643</code></a>
Avoid mem::uninitialized in par_sort_unstable</li>
<li><a
href="73b1061a23"><code>73b1061</code></a>
Merge <a
href="https://github-redirect.dependabot.com/rayon-rs/rayon/issues/705">#705</a></li>
<li><a
href="54c0b0dc0c"><code>54c0b0d</code></a>
Make sure that compat-Cargo.lock is fresh</li>
<li><a
href="4fd13b0334"><code>4fd13b0</code></a>
Regenerate compat-Cargo.lock</li>
<li>Additional commits viewable in <a
href="https://github.com/rayon-rs/rayon/compare/v1.5.3...rayon-core-v1.6.1">compare
view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-22 23:52:37 -05:00
dependabot[bot]
10e36c4233
Bump sysinfo from 0.26.4 to 0.27.7 (#7839) 2023-01-23 03:09:15 +00:00
dependabot[bot]
5cf47767d7
Bump shadow-rs from 0.16.3 to 0.20.0 (#7837) 2023-01-23 01:55:51 +00:00
dependabot[bot]
2aae8e6382
Bump regex from 1.6.0 to 1.7.1 (#7833) 2023-01-23 01:44:10 +00:00
Jakub Žádník
3552d03f6c
Allow main command to define top-level module command (#7764) 2023-01-22 21:34:15 +02:00
Vincenzo Carlino
8d5165c449
Feat/7725 url join (#7823)
# Description

Added command: `url join`.
Closes: #7725 

# User-Facing Changes

```
Converts a record to url

Search terms: scheme, username, password, hostname, port, path, query, fragment

Usage:
  > url join

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

Signatures:
  <record> | url join -> <string>

Examples:
  Outputs a url representing the contents of this record
  > {
          "scheme": "http",
          "username": "",
          "password": "",
          "host": "www.pixiv.net",
          "port": "",
          "path": "/member_illust.php",
          "query": "mode=medium&illust_id=99260204",
          "fragment": "",
          "params":
          {
            "mode": "medium",
            "illust_id": "99260204"
          }
        } | url join

  Outputs a url representing the contents of this record
  > {
        "scheme": "http",
        "username": "user",
        "password": "pwd",
        "host": "www.pixiv.net",
        "port": "1234",
        "query": "test=a",
        "fragment": ""
      } | url join

  Outputs a url representing the contents of this record
  > {
        "scheme": "http",
        "host": "www.pixiv.net",
        "port": "1234",
        "path": "user",
        "fragment": "frag"
      } | url join
```                  

# Questions
- Which parameters should be required? Currenlty are: `scheme` and
`host`.
2023-01-22 19:49:40 +01:00
Leon
d8027656b5
benchmark now pipes input into the closure (#7776)
# Description

Closes #7762. See issue for motivation.

# User-Facing Changes

Something like this is now possible without having to split this into 2
commands:
```
fetch "https://www.gutenberg.org/files/11/11-0.txt" | benchmark { str downcase | split words | uniq -c | sort-by count --reverse | first 10 }
```

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-01-22 19:18:28 +01:00
WindSoilder
4f57c5d56e
Fix multi-line redirection inside a block (#7808)
# Description

Fixes: #7786

The issue is because the lite block is wrong while converting from lex
tokens

# What happened internally?
Take the following as example:
```
❯ def foobar [] { 
    'hello' out> /tmp/output.1
    'world' out> /tmp/output.2
}
```

## Before:
```
LiteBlock { block: [
    LitePipeline { commands: [
        Command(None, LiteCommand { comments: [], parts: [Span { start: 40900, end:40907 }] }),
        Redirection(Span { start: 40908, end: 40912 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40913, end: 40926 }] })]
    },
    LitePipeline { commands: [
        Redirection(Span { start: 40908, end: 40912 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40929, end: 40936 }] }),   // this is wrong, should be command.
        Redirection(Span { start: 40937, end: 40941 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40942, end: 40955 }] })]
    }] }
```

## After:
```
LiteBlock { block: [
    LitePipeline { commands: [
        Command(None, LiteCommand { comments: [], parts: [Span { start: 40824, end: 40831 }] }),
        Redirection(Span { start: 40832, end: 40836 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40837, end: 40850 }] })] 
    },
    LitePipeline { commands: [
        Command(None, LiteCommand { comments: [], parts: [Span { start: 40854, end: 40861 }] }), 
        Redirection(Span { start: 40862, end: 40866 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 40867, end: 40880 }] })] 
    }
] }
```

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-23 06:32:56 +13:00
Maxim Zhiburt
69e7aa9fc9
nu-table: Wrap last column in table -e (#7778)
Hi  @rgwood thank you for report.

So this PR must fix it but I'd make a few runs.

close #7763

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-01-20 14:18:22 -08:00
KazukiY
cde56741fb
fetch -> http get and post -> http post (#7796)
# Updated description by @rgwood

This PR changes `fetch` to `http get` and `post` to `http post`. `fetch`
and `post` are now deprecated. [I surveyed people on
Discord](https://discord.com/channels/601130461678272522/601130461678272524/1065706282566307910)
and users strongly approved of this change.

# Original Description
This PR is related to #2741 and my first pull request in rust :)

Implemented a new http mod to better http support and alias `fetch` and
`post` commands to `http get` and `http post` respectively.

# User-Facing Changes

Users will be able to use HTTP method via http command, for example
``` shell
> http get "https://www.example.com"
<!doctype html>
<html>
...
```
2023-01-20 10:38:30 -08:00
Darren Schroeder
bbe694a622
fix signature display in help commands (#7802)
# Description

This PR fixes the signature display when running `help commands`. Before
this PR, there were leading spaces in the signatures column. Now,
they're left aligned for a cleaner look.

Before:

![image](https://user-images.githubusercontent.com/343840/213711847-368fba0d-c902-47e6-b777-54de978b1ce3.png)

After:

![image](https://user-images.githubusercontent.com/343840/213711551-c5eb29c9-1d47-444b-86a1-8e14711e9771.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-01-20 07:58:54 -06:00
Leon
7e575a718b
Do not list deprecated subcommands in help <cmd> (#7798)
# Description

BEFORE:
```
Subcommands:
  str camel-case - Convert a string to camelCase
  str capitalize - Capitalize first letter of text
  str collect - 'str collect' is deprecated. Please use 'str join' instead.
  str contains - Checks if string input contains a substring
  str distance - Compare two strings and return the edit distance/Levenshtein distance
  str downcase - Make text lowercase
  str ends-with - Check if an input ends with a string
  str find-replace - Deprecated command
  str index-of - Returns start index of first occurrence of string in input, or -1 if no match
  str join - Concatenate multiple strings into a single string, with an optional separator between each
  str kebab-case - Convert a string to kebab-case
  str length - Output the length of any strings in the pipeline
  str lpad - Left-pad a string to a specific length
  str pascal-case - Convert a string to PascalCase
  str replace - Find and replace text
  str reverse - Reverse every string in the pipeline
  str rpad - Right-pad a string to a specific length
  str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
  str snake-case - Convert a string to snake_case
  str starts-with - Check if an input starts with a string
  str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
  str title-case - Convert a string to Title Case
  str to-datetime - Deprecated command
  str to-decimal - Deprecated command
  str to-int - Deprecated command
  str trim - Trim whitespace or specific character
  str upcase - Make text uppercase
```

AFTER:

```
Subcommands:
  str camel-case - Convert a string to camelCase
  str capitalize - Capitalize first letter of text
  str contains - Checks if string input contains a substring
  str distance - Compare two strings and return the edit distance/Levenshtein distance
  str downcase - Make text lowercase
  str ends-with - Check if an input ends with a string
  str index-of - Returns start index of first occurrence of string in input, or -1 if no match
  str join - Concatenate multiple strings into a single string, with an optional separator between each     
  str kebab-case - Convert a string to kebab-case
  str length - Output the length of any strings in the pipeline
  str lpad - Left-pad a string to a specific length
  str pascal-case - Convert a string to PascalCase
  str replace - Find and replace text
  str reverse - Reverse every string in the pipeline
  str rpad - Right-pad a string to a specific length
  str screaming-snake-case - Convert a string to SCREAMING_SNAKE_CASE
  str snake-case - Convert a string to snake_case
  str starts-with - Check if an input starts with a string
  str substring - Get part of a string. Note that the start is included but the end is excluded, and that the first character of a string is index 0.
  str title-case - Convert a string to Title Case
  str trim - Trim whitespace or specific character
  str upcase - Make text uppercase
```

The deprecated subcommands still exist, but are no longer listed in
`help` for the containing command.

# User-Facing Changes

See above.

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-01-20 06:28:27 -06:00
Leon
ea9ca8b4ed
str length, str substring, str index-of, split words and split chars now use graphemes instead of UTF-8 bytes (#7752)
Closes https://github.com/nushell/nushell/issues/7742
2023-01-20 09:16:18 +02:00
pwygab
2982a2c963
let find take linebreaks into account in Value::String (#7789)
# Description

Fixes #7774. The functionality should be the same as feeding all
`PipelineDate::Value(Value::String(_,_),_)` into `lines` before putting
it into `find`.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-20 00:07:34 +01:00
Reilly Wood
3b5172a8fa
LazyRecord (#7619)
This is an attempt to implement a new `Value::LazyRecord` variant for
performance reasons.

`LazyRecord` is like a regular `Record`, but it's possible to access
individual columns without evaluating other columns. I've implemented
`LazyRecord` for the special `$nu` variable; accessing `$nu` is
relatively slow because of all the information in `scope`, and [`$nu`
accounts for about 2/3 of Nu's startup time on
Linux](https://github.com/nushell/nushell/issues/6677#issuecomment-1364618122).

### Benchmarks

I ran some benchmarks on my desktop (Linux, 12900K) and the results are
very pleasing.

Nu's time to start up and run a command (`cargo build --release;
hyperfine 'target/release/nu -c "echo \"Hello, world!\""' --shell=none
--warmup 10`) goes from **8.8ms to 3.2ms, about 2.8x faster**.

Tests are also much faster! Running `cargo nextest` (with our very slow
`proptest` tests disabled) goes from **7.2s to 4.4s (1.6x faster)**,
because most tests involve launching a new instance of Nu.

### Design (updated)

I've added a new `LazyRecord` trait and added a `Value` variant wrapping
those trait objects, much like `CustomValue`. `LazyRecord`
implementations must implement these 2 functions:

```rust
// All column names
fn column_names(&self) -> Vec<&'static str>;

// Get 1 specific column value
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;
 ```

### Serializability

`Value` variants must implement `Serializable` and `Deserializable`, which poses some problems because I want to use unserializable things like `EngineState` in `LazyRecord`s. To work around this, I basically lie to the type system:

1. Add `#[typetag::serde(tag = "type")]` to `LazyRecord` to make it serializable
2. Any unserializable fields in `LazyRecord` implementations get marked with `#[serde(skip)]`
3. At the point where a `LazyRecord` normally would get serialized and sent to a plugin, I instead collect it into a regular `Value::Record` (which can be serialized)
2023-01-18 19:27:26 -08:00
Zane Schaffer
be32aeee70
add magenta to ansi command as synonym for purple (#7785)
# Description

Added `magenta` as a synonym for Purple in the ansi command. Previously,
ansi errored out on `ansi magenta` as the `AnsiCode` vec didn't have
magenta as a name as seen in #7747.


<img width="909" alt="image"
src="https://user-images.githubusercontent.com/101823296/213012495-10bb29e3-b6d3-4fdc-bc3c-cb8a891c2bc2.png">




# User-Facing Changes

Users can now use the ANSI standard name `magenta`.
2023-01-17 19:50:55 -06:00
Racci
adcc74ab8d
Check all user groups. (#7775)
Previously the group check was only for the current users gid, now we
check against all the users groups.


# Description

Currently when using the `cd` command to enter a directory there was
only a check against the current user id, and exact current group id,
meaning if a directory had a group permission and that group wasn't the
users group it was effectively ignored.

The fix simply implements a check through all the users current groups.

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-01-17 19:49:54 -06:00
Justin Ma
f823c7cb5d
fix some typos (#7773)
# Description

Nothing changed, just fix some typos

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-01-16 12:43:46 +01:00
Darren Schroeder
26e6516626
update sqlparser dependency (#7772)
# Description

This PR updates the `sqlparser` dependency and updates code to the
latest api changes.

# 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-01-15 21:30:39 -06:00
dependabot[bot]
3ba1bfc369
Bump quick-xml from 0.25.0 to 0.27.1 (#7768) 2023-01-16 02:06:31 +00:00
dependabot[bot]
2611c9525e
Bump dialoguer from 0.9.0 to 0.10.3 (#7765) 2023-01-16 02:04:47 +00:00
WindSoilder
0353eb4a12
make save stream on list stream data (#7675)
# Description

Closes: #7590

# User-Facing Changes

So the following command
```
1..100 | each { |i| sleep 400ms; $i} | save --raw -f output.txt
```

Will stream data to `output.txt`

But I'm note sure how to make a proper test for it, so I leave with no
new test cases..

Also rename from `string_binary_list_value_to_bytes ` to
`value_to_bytes` to accepts more Value 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-01-15 10:54:30 -08:00
Vincenzo Carlino
92c4097f8d
Rename to url command to url build-query (#7702)
# Description

Refactor command: "to url" in: "to url query". Changed usage sentence.
Closes: #7495

# User-Facing Changes

Now we get a query string from a record or table by using command: "to
url query".

```
> help to url query
Convert record or table into query string applying percent-encoding.

Usage:
  > to url query

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

Signatures:
  <record> | to url query -> <string>
  <table> | to url query -> <string>

Examples:
  Outputs a query string representing the contents of this record
  > { mode:normal userid:31415 } | to url query

  Outputs a query string representing the contents of this 1-row table
  > [[foo bar]; ["1" "2"]] | to url query

  Outputs a query string representing the contents of this record
  > {a:"AT&T", b: "AT T"} | to url query
```

# Tests + Formatting

Added this test:
```
Example {
    description: "Outputs a query string representing the contents of this record",
    example: r#"{a:"AT&T", b: "AT T"} | to url query"#,
    result: Some(Value::test_string("a=AT%26T&b=AT+T")),
},
```
to ensure percent-encoding. 

# After Submitting

If PR is accepted I'll open another PR on documentation to notify
changes on
[this.](https://github.com/nushell/nushell.github.io/blob/main/book/commands/to_url.md)
2023-01-15 10:16:29 -08:00
Artemiy
a909c60f05
Ansi link (#7751) 2023-01-15 17:23:37 +02:00
Anton
7221eb7f39
Fix typos and use more idiomatic assertions (#7755)
I have changed `assert!(a == b)` calls to `assert_eq!(a, b)`, which give
better error messages. Similarly for `assert!(a != b)` and
`assert_ne!(a, b)`. Basically all instances were comparing primitives
(string slices or integers), so there is no loss of generality from
special-case macros,

I have also fixed a number of typos in comments, variable names, and a
few user-facing messages.
2023-01-15 15:03:32 +13:00
Reilly Wood
49ab559992
Trim quotes when shelling out to cmd.exe (#7740)
Closes #6337 and #5366. Prior to this PR, when "shelling out" to cmd.exe
on Windows we were not trimming quotes correctly:

```bash
〉^echo "foo"
\"foo\"
```
After this change, we do:
```bash
〉^echo "foo"
foo
```

### Breaking Change

I ended up removing `dir` from the list of supported cmd.exe internal
commands as part of this PR.

For this PR, I extracted the argument-cleaning-and-expanding code from
`spawn_simple_command()` for reuse in `spawn_cmd_command()`. This means
that we now expand globs, which broke some tests for the `dir` cmd.exe
internal command.

I probably could have kept the tests working, but... tbh, I don't think
it's worth it. I don't want to make the `cmd.exe` functionality any more
complicated than it already is, and calling `dir` from Nu is always
going to be weird+hacky compared to `ls`.
2023-01-13 11:00:30 -08:00
WindSoilder
3dd21c635a
dependency update: update polar to 0.26.1 (#7743)
# Description

As title

# 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-01-13 09:27:37 -06:00
Darren Schroeder
835bbb2e44
update base64 implementation to newer crate (#7739)
# Description

This PR updates the base64 crate, which has changed significantly, so
all the base64 implementations had to be changed too. Tests pass. I hope
that's enough.

# User-Facing Changes

None, except added a new character encoding imap-mutf7 as mutf7.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-13 07:16:14 -06:00
Nano
2ee2370a71
Detailed message during core dumped (#7737)
# Description

In bash when a program crashes, it prints the reason for what happened:
```
$ ./division_by_zero
Floating point exception (core dumped)
$ ./segfault
Segmentation fault (core dumped)
```

Nushell always prints the same thing in this case:
```
> ./division_by_zero
nushell: oops, process './division_by_zero' core dumped
Error: nu:🐚:external_command (link)
# etc..
```

This PR adds more detailed error printing, like in bash:
```
> ./division_by_zero
Floating point exception: oops, process './division_by_zero' core dumped
Error: nu:🐚:external_command (link)
# etc..
```

I made this message format as an example:
```
Floating point exception: oops, process './division_by_zero' core dumped
```
Instead of `nushell:` it writes a meaningful message, but I can change
this format as per the suggestions.

I tested the change only on linux, but it should work on other unix
systems.

# User-Facing Changes

The error message only.

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](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-01-13 10:22:11 +01:00
Leon
54dd65cfe1
Disallow encode's silent conversion to HTML entities (and add -i/--ignore-errors flag to re-allow it) (#7738)
# Description

Closes #7514.

* For both `encode` and `decode`: add a special case allowing `utf16` as
a valid alias for `utf-16` (just as `utf-8` has `utf8`).
* For `encode` , make it an error when encodings_rs replaces characters
outside the given encoding with HTML entities
* For `encode` , add `-i`/`--ignore-errors` flag to bring back this
behaviour.

Note: `--ignore-errors` does NOT ignore the error for using a wrong
encoding label like `uft8`

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

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-01-12 15:00:17 -06:00
Nupur Agrawal
b004aacd69
Add search terms in random and expression categories (#7736)
# Description

Refers to: [5093](https://github.com/nushell/nushell/issues/5093)

# Tests

- [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
2023-01-12 14:01:40 +01:00
WindSoilder
48b7b415e2
spanned error on path exists command (#7717)
# Description

Closes: #7696 

# User-Facing Changes

Before:
```
❯ 'temp/aa' | path exists
Error: nu:🐚:io_error (link)

  × I/O error
  help: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }
```

After:
```
❯ 'temp/aa' | path exists
Error: nu:🐚:io_error (link)

  × I/O error
   ╭─[entry #42:1:1]
 1 │ 'temp/aa' | path exists
   · ────┬────
   ·     ╰── Permission denied (os error 13)
   ╰────
```
# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-12 06:56:39 -06:00
dependabot[bot]
544cea95e1
Bump uuid from 1.1.2 to 1.2.2 (#7734) 2023-01-12 12:48:49 +00:00
WindSoilder
8aa2632661
Support redirect err and out to different streams (#7685)
# Description

Closes: #7364 

# User-Facing Changes

Given the following shell script:
```bash
x=$(printf '=%.0s' {1..100})
echo $x
echo $x 1>&2
```

It supports the following command:
```
bash test.sh out> out.txt err> err.txt
```

Then both `out.txt` and `err.txt` will contain `=`(100 times)

## About the change

The core idea is that when doing lite-parsing, introduce a new variant
`LiteElement::SeparateRedirection` if we meet two Redirection
token(which is generated by `lex` function),
During converting from lite block to block,
`LiteElement::SeparateRedirection` will be converted to
`PipelineElement::SeparateRedirection`.

Then in the block eval process, if we get
`PipelineElement::SeparateRedirection`, we invoke `save` command with
`--stderr` arguments to acthive our behavior.



## What happened internally?
Take the following command as example:
```
^ls out> out.txt err> err.txt
```

lex parsing result(`Tokens`) are not changed, but `LiteBlock` and
`Block` is changed after this pr.

### LiteBlock before
```rust
LiteBlock {
    block: [
        LitePipeline { commands: [
            Command(None, LiteCommand { comments: [], parts: [Span { start: 39041, end: 39044 }] }),
            // actually the span of first Redirection is wrong too..
            Redirection(Span { start: 39058, end: 39062 }, Stdout, LiteCommand { comments: [], parts: [Span { start: 39050, end: 39057 }] }),
            Redirection(Span { start: 39058, end: 39062 }, Stderr, LiteCommand { comments: [], parts: [Span { start: 39063, end: 39070 }] })
        ]
    }]
}
```
### LiteBlock after
```rust
LiteBlock {
    block: [
        LitePipeline { commands: [
            Command(
                None, 
                LiteCommand { comments: [], parts: [Span { start: 38525, end: 38528 }] }),
                // new one! two Redirection merged into one SeparateRedirection.
                SeparateRedirection { 
                    out: (Span { start: 38529, end: 38533 }, LiteCommand { comments: [], parts: [Span { start: 38534, end: 38541 }] }),
                    err: (Span { start: 38542, end: 38546 }, LiteCommand { comments: [], parts: [Span { start: 38547, end: 38554 }] })
                }
        ]
    }]
}
```

### Block before
```rust
Pipeline {
    elements: [
        Expression(None, Expression {
            expr: ExternalCall(Expression { expr: String("ls"), span: Span { start: 39042, end: 39044 }, ty: String, custom_completion: None }, [], false),
            span: Span { start: 39041, end: 39044 },
            ty: Any, custom_completion: None 
        }),
        Redirection(Span { start: 39058, end: 39062 }, Stdout, Expression { expr: String("out.txt"), span: Span { start: 39050, end: 39057 }, ty: String, custom_completion: None }),
        Redirection(Span { start: 39058, end: 39062 }, Stderr, Expression { expr: String("err.txt"), span: Span { start: 39063, end: 39070 }, ty: String, custom_completion: None })] }
```

### Block after
```rust
Pipeline {
    elements: [
        Expression(None, Expression {
            expr: ExternalCall(Expression { expr: String("ls"), span: Span { start: 38526, end: 38528 }, ty: String, custom_completion: None }, [], false),
            span: Span { start: 38525, end: 38528 },
            ty: Any,
            custom_completion: None 
        }),
        // new one! SeparateRedirection
        SeparateRedirection {
            out: (Span { start: 38529, end: 38533 }, Expression { expr: String("out.txt"), span: Span { start: 38534, end: 38541 }, ty: String, custom_completion: None }),
            err: (Span { start: 38542, end: 38546 }, Expression { expr: String("err.txt"), span: Span { start: 38547, end: 38554 }, ty: String, custom_completion: None }) 
        }
    ]
}
```
# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](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-01-12 10:22:30 +01:00
WindSoilder
5419e8ae9d
don't expand tilde if we quote external arguments (#7711)
# Description

As title
Fixes: #7673
Fixes: #4205
Also possiblely fixes: https://github.com/nushell/nushell/issues/6993

# User-Facing Changes

Before:
```
> ^echo "~"
/Users/ttt
```

After:
```
> ^echo "~"
~
```
# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-11 19:14:19 -05:00
dependabot[bot]
d4d28ab796
Bump once_cell from 1.16.0 to 1.17.0 (#7732) 2023-01-11 23:00:44 +00:00
Stefan Holderbach
1ae9157985
Bump to 0.74.1 development version (#7721)
# Description

May be used for hotfix if needed
2023-01-11 22:30:41 +01:00
Justin Ma
206a6ae6c9
Fix generated doc for explore commands (#7723)
# Description

Fix generated doc for `explore` commands, and resolve the static site
build error:
https://github.com/nushell/nushell.github.io/actions/runs/3889029668/jobs/6636921318

# 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-01-11 11:17:12 +08:00
Xoffio
82ac590412
Progress bar Implementation (#7661)
# Description

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

I implemented the status bar we talk about yesterday. The idea was
inspired by the progress bar of `wget`.
I decided to go for the second suggestion by `@Reilly`
> 2. add an Option<usize> or whatever to RawStream (and ListStream?) for
situations where you do know the length ahead of time

For now only works with the command `save` but after the approve of this
PR we can see how we can implement it on commands like `cp` and `mv`

When using `fetch` nushell will check if there is any `content-length`
attribute in the request header. If so, then `fetch` will send it
through the new `Option` variable in the `RawStream` to the `save`.
If we know the total size we show the progress bar 

![nu_pb01](https://user-images.githubusercontent.com/38369407/210298647-07ee55ea-e751-41b1-a84d-f72ec1f6e9e5.jpg)
but if we don't then we just show the stats like: data already saved,
bytes per second, and time lapse.

![nu_pb02](https://user-images.githubusercontent.com/38369407/210298698-1ef65f51-40cc-4481-83de-309cbd1049cb.jpg)

![nu_pb03](https://user-images.githubusercontent.com/38369407/210298701-eef2ef13-9206-4a98-8202-e4fe5531d79d.jpg)

Please let me know If I need to make any changes and I will be happy to
do it.

# User-Facing Changes

A new flag (`--progress` `-p`) was added to the `save` command 
Examples:
```nu
fetch https://github.com/torvalds/linux/archive/refs/heads/master.zip | save --progress -f main.zip
fetch https://releases.ubuntu.com/22.04.1/ubuntu-22.04.1-desktop-amd64.iso | save --progress -f main.zip
open main.zip --raw | save --progress main.copy
```

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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
-
I am getting some errors and its weird because the errors are showing up
in files i haven't touch. Is this normal?

# After Submitting

If your PR had any user-facing changes, update [the
documentation](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-01-10 20:57:48 -05:00
Stefan Holderbach
8044fb2db0
Bump version to 0.74.0 (#7718)
Preparing the release
2023-01-10 20:58:13 +01:00
Leon
3a59ab9f14
Improve wording of str replace help messages (#7708)
# Description

See title.

# User-Facing Changes

See title.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-10 20:46:50 +01:00
Reilly Wood
80463d12fb
Revert "Primitives now use color closures..." (#7710)
This temporarily reverts commit c5639cd9fa
(PR https://github.com/nushell/nushell/pull/7650). See
[here](https://github.com/nushell/nushell/pull/7650#issuecomment-1375036213)
for details; the PR is accidentally adding ANSI escape codes to strings
piped to externals.

I think we should revert the PR because we're only 1-2 days away from a
release; reverting it will give us more time to land+test a proper fix
in the next release cycle.
2023-01-08 21:53:52 -08:00
Michael Angerman
95cd9dd2b2
move BufferedReader out of nu-command (#7697)
src/main.rs has a dependency on BufferedReader
which is currently located in nu_command.

I am moving BufferedReader to a more relevant
location (crate) which will allow / eliminate main's dependency
on nu_command in a benchmark / testing environment...

now that @rgwood  has landed benches I want
to start experimenting with benchmarks related
to the parser.

For benchmark purposes when dealing with parsing
you need a very simple set of commands that show
how well the parser is doing, in other words
just the core commands... Not all of nu_command...

Having a smaller nu binary when running the benchmark CI
would enable building nushell quickly, yet still show us
how well the parser is performing...

Once this PR lands the only dependency main will have
on nu_command is create_default_context ---
meaning for benchmark purposes we can swap in a tiny
crate of commands instead of the gigantic nu_command
which has its "own" create_default_context...

It will also enable other crates going forward to
use BufferedReader.  Right now it is not accessible
to other lower level crates because it is located in a
"top of the stack crate".
2023-01-06 15:22:17 -08:00
Amirhossein Akhlaghpour
9b617de6f0
Continue and Break on Try/Catch (#7683)
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
Fixes https://github.com/nushell/nushell/issues/7656
2023-01-05 21:41:51 +01:00
Mehul Gaidhani
26d1307476
Url encode to escape special characters (#7664)
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-01-05 19:24:38 +01:00
Jakub Žádník
86707b9972
Remove environment variable hiding from hide (#7687) 2023-01-05 20:08:43 +02:00
Zack Penn
3ea027a136
Make user parameter optional in fetch (#7680)
# Description

This commit makes the `user` parameter optional in the `fetch` command.
Previously when attempting to _only_ pass a `password`, the command
would ignore authentication. Now when a `user` is not supplied, but a
`password` is, an empty user is implied.

Before this PR, consider the following:
```nushell
fetch -password "mypassword" $url
```
This would result in the `password` parameter being ignored entirely.

Now, with changes made in this PR, consider the same code snippet as
above. The following HTTP header will be used:
```
Authentication: Basic <base64_encode(":{password}")>
```
Note that the `user` field is implied as empty if one is not supplied
when `password` is.

# User-Facing Changes

* `fetch` now supports `password`-only authentication, using an empty
`user` if one is not supplied.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-04 19:57:56 -08:00
Stefan Holderbach
9bc4e6794d
Remove math eval command (#7284)
Reasoning: 

Most missing math commands are implemented with #7258.
The `meval` crate itself declares that it doesn't strive to stringent
standards (https://docs.rs/meval/latest/meval/#related-projects).
For example no particular special casing or transformations are
performed to ensure numerical stability. It uses the same rust `std`
library functions we use or have access to (and `f64`).
While the command call syntax in nushell may be a bit more verbose,
having a single source of truth and common commands is beneficial.
Furthermore the `math` commands can themselves implement broadcasting
over lists (or table columns).

Closes #7073

Removed dependencies:
- `meval`
- `nom 1.2.4` (duplicate)

User-Facing Changes:

Scripts using `math eval` will break. 
We remove a further `eval` like behavior to get results through runtime evaluation (albeit limited in scope)

Tests:

- Updated tests that internally used `math eval`.
- Removed one test that primarily used `math eval` to obtain a result from `str join`
2023-01-04 23:50:18 +01:00
Stefan Holderbach
429127793f
[Chore] cleanup in where implementation (#7679)
- Remove commented out example that is unnecessary after #7365
- remove unnecessary closure map
2023-01-04 22:50:02 +01:00
raccmonteiro
75cb3fcc5f
uniq and uniq-by optimization (#7477) (#7534)
# Description

Refactored the quadratic complexity on `uniq` to use a HashMap, as key I
converted the Value to string.
I tried to use the HashableValue, but it looks it is not very developed
yet and it was getting more complex and difficult.

This improves performance on large data sets.

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


# Tests + Formatting
```
> let data = fetch "https://home.treasury.gov/system/files/276/yield-curve-rates-1990-2021.csv"
> $data | uniq
```

it keeps original attribute order in Records:
```
> [ {b:2, a:1} {a:1, b:2} ] | uniq 
╭───┬───┬───╮
│ # │ b │ a │
├───┼───┼───┤
│ 0 │ 2 │ 1 │
╰───┴───┴───╯
```
2023-01-04 11:35:49 -08:00
Leon
c5639cd9fa
Primitives now use color closures when printed on the command line (#7650)
# Description

Closes #7554


![image](https://user-images.githubusercontent.com/83939/210177700-4890fcf2-1be9-4da9-9974-58d4ed403430.png)

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

Co-authored-by: Reilly Wood <26268125+rgwood@users.noreply.github.com>
2023-01-03 23:59:10 -08:00
Reilly Wood
95d4922e44
Make stream info visible to users in describe (#7589)
Closes #7581.

After this PR, `describe` shows `(stream)` next to input that arrived at
`describe` as a `ListStream`:
```bash
〉ls | describe
table<name: string, type: string, size: filesize, modified: date> (stream)
〉[1 2 3] | each {|i| $i} | describe
list<int> (stream)
```

`describe` must collect all items of the stream to display type
information for lists and tables. If users need to avoid collecting
input, they can use the `-n`/`--no-collect` flag:

```bash
〉[1 2 3] | each {|i| $i} | describe --no-collect
stream
```
2023-01-03 21:08:05 -08:00
Reilly Wood
249afc5df4
Clarify url base command (#7670)
I noticed that the help for the `url` command was confusing (it wasn't
clear that `url` is just a base command that does nothing itself) and
the input type was also wrong. Fixed.

Before:
```bash
〉help url
Apply url function.

Search terms: network, parse

Usage:
  > url 

Subcommands:
  url parse - Parses a url

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

Signatures:
  <string> | url -> <string>
```

After:
```bash
〉help url
Various commands for working with URLs

You must use one of the following subcommands. Using this command as-is will only produce this help message.

Search terms: network, parse

Usage:
  > url 

Subcommands:
  url parse - Parses a url

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

Signatures:
  <nothing> | url -> <string>
  ```
2023-01-03 15:49:43 -08:00
pwygab
6862734580
let start open anything and everything (#7580)
# Description

Fixes #7546 's request. I'm unsure, so hopefully someone in charge of
design can chip in.

# User-Facing Changes

`open` now opens directories in the default file manager.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-03 10:47:37 -08:00
Artemiy
9e1f645428
Fix save error handling (#7608)
Closes #5178

Modularizes `save` implementation
2023-01-03 14:22:28 +01:00
WindSoilder
d1a78a58cd
revert changes on prepend and append (#7660)
# Description

#7623 causes a break on PATH convertion, this pr is going to revert
`prepend` and `append` bahavior.

# 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-01-02 17:09:55 -08:00
Leon
65d0b5b9d9
Make get hole errors and cell path hole errors identical (improvement on #7002) (#7647)
# Description

This closes #7498, as well as fixes an issue reported in
https://github.com/nushell/nushell/pull/7002#issuecomment-1368340773

BEFORE:
```
〉[{foo: 'bar'} {}] | get foo
Error: nu:🐚:column_not_found (link)

  × Cannot find column
   ╭─[entry #5:1:1]
 1 │ [{foo: 'bar'} {}] | get foo
   · ────────┬────────   ─┬─
   ·         │            ╰── value originates here
   ·         ╰── cannot find column 'Empty cell'
   ╰────

〉[{foo: 'bar'} {}].foo
╭───┬─────╮
│ 0 │ bar │
│ 1 │     │
╰───┴─────╯
```
AFTER:
```
〉[{foo: 'bar'} {}] | get foo
Error: nu:🐚:column_not_found (link)

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

〉[{foo: 'bar'} {}].foo
Error: nu:🐚:column_not_found (link)

  × Cannot find column
   ╭─[entry #3:1:1]
 1 │ [{foo: 'bar'} {}].foo
   ·               ─┬  ─┬─
   ·                │   ╰── cannot find column 'foo'
   ·                ╰── value originates here       
   ╰────
```

EDIT: This also changes the semantics of `get`/`select` `-i` somewhat.
I've decided to leave it like this because it works more intuitively
with `default` and `compact`.
BEFORE:
```
〉[{a:1} {b:2} {a:3}] | select -i foo | to nuon
null
```
AFTER:
```
〉[{a:1} {b:2} {a:3}] | select -i foo | to nuon
[[foo]; [null], [null], [null]]
```

# User-Facing Changes

See above. EDIT: the issue with holes in cases like ` [{foo: 'bar'}
{}].foo.0` versus ` [{foo: 'bar'} {}].0.foo` has been resolved.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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-01-02 14:45:43 -08:00
Access
ececca7ad2
fix: ci problem (#7643) 2022-12-31 14:00:35 +02:00
WindSoilder
e9cc417fd5
last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623)
Closes https://github.com/nushell/nushell/issues/6941
2022-12-31 13:35:12 +02:00
Access
81a7d17b33
return Error if get meet nothing and without "i" (#7002) 2022-12-31 13:27:09 +02:00
Access
9382dd6d55
fix: empty cell in select (#7639) 2022-12-31 13:19:10 +02:00
Leon
7aa2a57434
def: make various punctuation misuses into errors (#7624)
Closes https://github.com/nushell/nushell/issues/7604
2022-12-31 13:18:53 +02:00
Jakub Žádník
8bfcea8054
Expand Nushell's help system (#7611) 2022-12-30 17:44:37 +02:00
Stefan Holderbach
be31182969
Fix quoting of empty string in to nuon (#7632)
Closes https://github.com/nushell/nushell/issues/7631
2022-12-30 09:49:35 +01:00
Stefan Holderbach
b543063749
Fix the syntax highlighting in help metadata (#7628) 2022-12-29 17:45:55 +01:00
Stefan Holderbach
35b12fe5ec
Fix usage of deprecated C-style logical and (#7627)
n untested examples we still had `&&`
2022-12-29 16:47:33 +01:00
Leon
6ac26094da
Slight edits to ls and zip's help text (#7626) 2022-12-29 16:24:08 +01:00
Mikołaj Powierża
8c6a0f68d4
Update powierza-coefficient to 1.0.2 (#7625) 2022-12-29 15:55:00 +01:00
Leon
f5d6672ccf
Disallow ^ in def command names (#7606)
# Description

Closes #7273.

Also slightly edits/tidies up parser.rs.

# User-Facing Changes

`^` is now forbidden in `def` and `def-env` command names. EDIT: also
`alias`.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-27 15:00:44 -08:00
Darren Schroeder
db06edc5d3
add --mime-type(-m) to ls in the type column (#7616)
# Description

This PR adds the `mime-type` to the `type` column if you add the
`--mime-type(-m)` flag to `ls`.
<img width="853" alt="Screenshot 2022-12-27 at 11 43 20 AM"
src="https://user-images.githubusercontent.com/343840/209705499-27fe40fe-0356-4d9d-97f2-4b2dc52e0963.png">

<img width="781" alt="Screenshot 2022-12-27 at 11 45 53 AM"
src="https://user-images.githubusercontent.com/343840/209705509-4d677389-fd68-401e-a7af-3fc6052743b6.png">

# User-Facing Changes

If you specify the `-m` flag, you get the "guessed at" mime type. The
guess is based on the file name and uses this crate
https://docs.rs/mime_guess/latest/mime_guess/ for the guessing.

Part of issue #7612 and and #7524

There's some debate on if the `mime-type` should be added to the `type`
column or if there should be a separate `mime` column. I tend to lean on
the side of `type` since it's technically a type and it's only in that
column if you ask it to be there. Also, I'd prefer to reuse a column
rather than having a list of sprawling columns. Also, as @KodiCraft
suggested, there is precedence as with `ls -d` where the summed size is
in the size column.

I could go either way and if someone wants to create a `mime` column,
we'd probably accept it.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-27 12:46:23 -06:00
Amirhossein Akhlaghpour
568927349d
Fix and Allow Number and Boolean type to be key in from yaml (#7607)
Fix and Allow Number and Boolean type to be key in Yaml .

For example : 
`"200 : " | from yaml` not allowed because of Number key type.

PR allow , we can use Boolean and Number for key. 
For example :
`"true : false" | from yaml`
`"5050 : it is number" | from yaml`

Fixes #7222 .
2022-12-27 08:28:24 -08:00
Maxim Zhiburt
4f812a7f34
Fix table expand wrap in case no header is there (#7605)
ref #7598

To be honest I was not able to obtain such results in basic mode as you
@rgwood.
But I've got it in `table -e`.

So this must fix the `table -e` wrapping.

Could you verify if it got fixed?

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-12-27 07:44:34 -06:00
Justin Ma
38fc42d352
Fix const examples (#7610)
# Description

Fix const examples

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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
2022-12-27 15:44:03 +08:00
Justin Ma
b4c5693ac6
Fix an example of env command (#7603)
# Description

Fix an example of `env` 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.
2022-12-26 16:40:34 +08:00
Kian-Meng Ang
79000aa5e0
Fix typos by codespell (#7600)
# Description

Found via `codespell -S target -L
crate,ser,numer,falsy,ro,te,nd,bu,ndoes,statics,ons,fo,rouge,pard`

# User-Facing Changes

None.

# Tests + Formatting

None and done.

# After Submitting

None.
2022-12-26 02:31:26 -05:00
Maxim Zhiburt
b499e7c682
Fix some issues with table wrapping of lists (#7598)
close #7591 

I tend to think it must be addressed.
But I'd verify it @rgwood.

PS: I've noticed how `table -e` and `table` with the same width wraps a
bit differently sometimes. (I guess it also must be addressed......)

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-12-24 18:27:34 -06:00
Artemiy
ddc00014be
To toml fix (#7597)
# Description

Fixes #7510 .
Remove support for tables from `to toml` command and update description.
Previously, as indicated in #7510 , a table could be converted to toml
and would result in this invalid toml:


![image](https://user-images.githubusercontent.com/17511668/209443930-c3dd3a3f-5ffd-4273-9c10-acbb345c788e.png)

This commit removes functionality of serializing tables and now `to
toml` produces an error:


![image](https://user-images.githubusercontent.com/17511668/209443975-be119465-8946-4644-8994-489ca94f6006.png)

The `from toml` command already acknowledges the fact that toml can
contain only records as indicated in its signature


![image](https://user-images.githubusercontent.com/17511668/209443995-1590d044-a790-4be3-a967-b26292a6e70c.png)

Now help of `to toml` reflects this feature of format as well:


![image](https://user-images.githubusercontent.com/17511668/209444014-7cfe8f8e-ad8a-4845-a151-24df6b99a1a2.png)

Additionally new tests were created for `to toml` command. See
`crates\nu-command\tests\format_conversions\toml.rs`.

Also removed undocumented behavior that would accept and validate a
string as toml:


![image](https://user-images.githubusercontent.com/17511668/209449482-5d876074-fc5b-4b21-b8a5-64e643a50083.png)


# User-Facing Changes

- Serializing tables to toml now produces error instead of invalid toml
- Updated `to toml` help
- Remove undocumented "validation" (not really user-facing)

# 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.
2022-12-24 15:12:09 -06:00
Amirhossein Akhlaghpour
9ffa3e55c2
Fix #6888 and rename fill-na to fill-nan (#7565)
Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
Fixes https://github.com/nushell/nushell/issues/6888
2022-12-24 16:04:46 +01:00
Stefan Holderbach
45fe3be83e
Further cleanup of Span::test_data usage + span fixes (#7595)
# Description

Inspired by #7592

For brevity use `Value::test_{string,int,float,bool}`

Includes fixes to commands that were abusing `Span::test_data` in their
implementation. Now the call span is used where possible or the explicit
`Span::unknonw` is used.

## Command fixes
- Fix abuse of `Span::test_data()` in `query_xml`
- Fix abuse of `Span::test_data()` in `term size`
- Fix abuse of `Span::test_data()` in `seq date`
- Fix two abuses of `Span::test_data` in `nu-cli`
- Change `Span::test_data` to `Span::unknown` in `keybindings listen`
- Add proper call span to `registry query`
- Fix span use in `nu_plugin_query`
- Fix span assignment in `select`
- Use `Span::unknown` instead of `test_data` in more places

## Other
- Use `Value::test_int`/`test_float()` consistently
- More `test_string` and `test_bool`
- Fix unused imports


# User-Facing Changes

Some commands may now provide more helpful spans for downstream use in
errors
2022-12-24 07:41:57 -06:00
Leon
dd6fe6a04a
Add extra_usage messages for subcommand-only commands (#7594)
# Description

The message reads "You must use one of the following subcommands. Using
this command as-is will only produce this help message." and is added to
commands like `into`, `bytes`, `str`, etc.

# 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.
2022-12-24 07:16:29 -06:00
Leon
e76b38882c
columns now errors when given a non-record non-table (#7593)
# Description

This is for consistency with the new `values` command. Previously it
would return a completely empty record (??!) when given an
incorrectly-typed value.

# User-Facing Changes

See title.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-24 07:08:25 -06:00
Leon
11bdab7e61
Change instances of Value::string("foo", Span::test_data()) to Value::test_string("foo") (#7592) 2022-12-24 10:25:38 +01:00
Reilly Wood
3d682fe957
Fix error message when interrupting table with ctrl+c (#7588)
`table` was displaying an incorrect "Couldn't fit table into X columns!"
error when streaming was interrupted by `ctrl+c`:

![image](https://user-images.githubusercontent.com/26268125/209415204-cc20964b-fc43-42a0-867f-1b01cefb3213.png)

This PR fixes that:

![image](https://user-images.githubusercontent.com/26268125/209415163-b3041357-7f16-4a17-b15a-170b4d50f5ee.png)
2022-12-23 16:38:38 -08:00
Darren Schroeder
3be7996e79
add metadata to wrap (#7586)
# Description

This PR allows `wrap` to pass through metadata.

# User-Facing Changes

This change allows this:
<img width="789" alt="Screenshot 2022-12-23 at 3 12 37 PM"
src="https://user-images.githubusercontent.com/343840/209406010-1da9b814-1892-4961-bb01-9f88ddc83474.png">
Instead of this:
<img width="786" alt="Screenshot 2022-12-23 at 3 12 48 PM"
src="https://user-images.githubusercontent.com/343840/209406021-6e5eb860-0911-42c4-a39e-5fe76c61af03.png">

Strangely enough, this command doesn't result in LS_COLORS `(ls |
values).0 | wrap name`

/cc @webbedspace - we were talking about LS_COLORS in `values` earlier.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-23 15:56:28 -06:00
Leon
b16b3c0b7f
Add values command (see #7166) (#7583) 2022-12-23 12:49:19 -06:00
Leon
852ec3f9a0
Fix signatures of commands which accept records also (#7582)
# Description

Certain commands that operate on tables also work on bare records, but
their type sig didn't reflect that. This corrects this.

I did not fix certain commands which, I feel, currently give unintended
behaviour when given plain records. These are `sort-by` and `uniq-by`.

Also corrected the wording of some stuff in headers.rs, and removed a
wrong comment in insert.rs.

# 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.
2022-12-23 07:38:37 -06:00
Leon
dd7b7311b3
Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217)
# Description

* I was dismayed to discover recently that UnsupportedInput and
TypeMismatch are used *extremely* inconsistently across the codebase.
UnsupportedInput is sometimes used for input type-checks (as per the
name!!), but *also* used for argument type-checks. TypeMismatch is also
used for both.
I thus devised the following standard: input type-checking *only* uses
UnsupportedInput, and argument type-checking *only* uses TypeMismatch.
Moreover, to differentiate them, UnsupportedInput now has *two* error
arrows (spans), one pointing at the command and the other at the input
origin, while TypeMismatch only has the one (because the command should
always be nearby)
* In order to apply that standard, a very large number of
UnsupportedInput uses were changed so that the input's span could be
retrieved and delivered to it.
* Additionally, I noticed many places where **errors are not propagated
correctly**: there are lots of `match` sites which take a Value::Error,
then throw it away and replace it with a new Value::Error with
less/misleading information (such as reporting the error as an
"incorrect type"). I believe that the earliest errors are the most
important, and should always be propagated where possible.
* Also, to standardise one broad subset of UnsupportedInput error
messages, who all used slightly different wordings of "expected
`<type>`, got `<type>`", I created OnlySupportsThisInputType as a
variant of it.
* Finally, a bunch of error sites that had "repeated spans" - i.e. where
an error expected two spans, but `call.head` was given for both - were
fixed to use different spans.

# Example
BEFORE
```
〉20b | str starts-with 'a'
Error: nu:🐚:unsupported_input (link)

  × Unsupported input
   ╭─[entry #31:1:1]
 1 │ 20b | str starts-with 'a'
   ·   ┬
   ·   ╰── Input's type is filesize. This command only works with strings.
   ╰────

〉'a' | math cos
Error: nu:🐚:unsupported_input (link)

  × Unsupported input
   ╭─[entry #33:1:1]
 1 │ 'a' | math cos
   · ─┬─
   ·  ╰── Only numerical values are supported, input type: String
   ╰────

〉0x[12] | encode utf8
Error: nu:🐚:unsupported_input (link)

  × Unsupported input
   ╭─[entry #38:1:1]
 1 │ 0x[12] | encode utf8
   ·          ───┬──
   ·             ╰── non-string input
   ╰────
```
AFTER
```
〉20b | str starts-with 'a'
Error: nu:🐚:pipeline_mismatch (link)

  × Pipeline mismatch.
   ╭─[entry #1:1:1]
 1 │ 20b | str starts-with 'a'
   ·   ┬   ───────┬───────
   ·   │          ╰── only string input data is supported
   ·   ╰── input type: filesize
   ╰────

〉'a' | math cos
Error: nu:🐚:pipeline_mismatch (link)

  × Pipeline mismatch.
   ╭─[entry #2:1:1]
 1 │ 'a' | math cos
   · ─┬─   ────┬───
   ·  │        ╰── only numeric input data is supported
   ·  ╰── input type: string
   ╰────

〉0x[12] | encode utf8
Error: nu:🐚:pipeline_mismatch (link)

  × Pipeline mismatch.
   ╭─[entry #3:1:1]
 1 │ 0x[12] | encode utf8
   · ───┬──   ───┬──
   ·    │        ╰── only string input data is supported
   ·    ╰── input type: binary
   ╰────
```

# User-Facing Changes

Various error messages suddenly make more sense (i.e. have two arrows
instead of one).

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` 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.
2022-12-23 01:48:53 -05:00
Reilly Wood
9364bad625
Make to text stream ListStreams (#7577)
This PR changes `to text` so that when given a `ListStream`, it streams
the incoming values instead of collecting them all first.

The easiest way to observe/verify this PR is to convert a list to a very
slow `ListStream` with `each`:
```bash
ls | get name | each {|n| sleep 1sec; $n} | to text
```
The `to text` output will appear 1 item at a time.
2022-12-22 16:38:07 -08:00
pwygab
6fc5244439
tighter restrictions on alias and def names (#7392)
# Description

Prevent a situation where a `def` can't be run due to a poor choice of
name. Related: #6335. Hashtags, numbers and filesizes are no longer
allowed. `alias` check has been moved because previously `alias 123`
would be caught but `alias "123"` would be permitted.

# User-Facing Changes

Some definitions can no longer be made, but because they couldn't be run
previously anyway, it doesn't really matter.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-22 12:31:34 -08:00
Leon
8e1112c1dd
Change other instances of $nothing to null (#7569)
# Description

Purely for consistency, various remaining instances of `$nothing`
(almost all of which were in test code) have been changed to `null`.
Now, the only place that refers to `$nothing` is the parser code which
implements it.

# User-Facing Changes

The default config.nu now uses `null` in certain places where it used
`$nothing`.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-22 12:30:10 -08:00
Leon
9d1cb1bfaf
Make $in work in catch closures (#7458)
# Description

This now works:
```
try { 'x' | math abs } catch { $in }
```

# 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.
2022-12-22 09:35:41 -06:00
Leon
5b616770df
Make config.filesize_format/config.filesize_metric conflict resolution consistent (#7410)
# Description

Currently, `filesize_format`/`filesize_metric` conflicts are resolved as
follows: if the `filesize_format` ends in "ib", then that overrides
`filesize_metric`, otherwise, `filesize_metric` overrides
`filesize_format`. This removes this difficult-to-predict asymmetric
behaviour, and makes it so that `filesize_metric` always overrides
`filesize_format`.

This also adds tests for `$env.config.filesize.format` and
`$env.config.filesize.metric` values.

REMINDER: `filesize_metric` means "increments of 1000", and refers to
KB-MB-GB-TB etc.

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

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2022-12-22 08:46:55 -06:00
Jakub Žádník
23a5c5dc09
Remove shape-directed import pattern parsing (#7570) 2022-12-22 16:36:13 +02:00
WindSoilder
046e46b962
avoid panic when using from nuon (#7533)
# Description

Fixes #5996 

Just found a relative easy way to fix the issue

# User-Facing Changes

```
❯ open $nu.plugin-path | from nuon
Error:
  × error when loading nuon text
   ╭─[entry #36:1:1]
 1 │ open $nu.plugin-path | from nuon
   ·                        ────┬────
   ·                            ╰── could not load nuon text
   ╰────

Error:
  × Error when loading


❯ open $nu.config-path | from nuon
Error:
  × error when loading nuon text
   ╭─[entry #37:1:1]
 1 │ open $nu.config-path | from nuon
   ·                        ────┬────
   ·                            ╰── could not load nuon text
   ╰────

Error:
  × error when loading
```

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-21 16:42:23 -08:00
Stefan Holderbach
ec08e4bc6d
Fix && quotation in to nuon after proptest fail (#7564)
`proptest` caught a failing test condition for `&&` as a literal string. It requires a quotation to be parsed correctly by current `from nuon`
    
https://github.com/nushell/nushell/actions/runs/3753242377/jobs/6376308675

The change in the parser that now returns an error was introduced by https://github.com/nushell/nushell/pull/7241

This in theory doesn't have to be an error (it is a diagnostic for nushell code) but it is probably better safe than sorry to require quotation here.

- Add a test for `&&` in `to nuon` from proptest fail
- Fix `to nuon` generating invalid `&&` literal
- Add a test for `,` in `to nuon`/`from nuon` cycle
  - Bonus: should already be properly quoted
2022-12-22 00:36:07 +01:00
Reilly Wood
05e07ddf5c
Add some cell path tests (#7563) 2022-12-21 23:54:39 +01:00
Jakub Žádník
757d7479af
Add "fall-through" signatures (#7527)
Fixes https://github.com/nushell/nushell/issues/4659
Fixes https://github.com/nushell/nushell/issues/5294
Fixes https://github.com/nushell/nushell/issues/6124
fix https://github.com/nushell/nushell/issues/5103
2022-12-22 00:33:26 +02:00
Reilly Wood
22c50185b5
table: Check stream timeout on every item (#7509)
`table` handles slow `ListStream`s in a special way: every 100 items, it
checks whether 1 second has elapsed since the last table page, and if so
it outputs a new page with all the items in its buffer.

**I would like to remove the "every 100 items" condition and always
output whatever we have if a second has elapsed.** I think this will be
a better user experience for very slow streams.

As a motivating example, imagine tailing a log file and doing some
string parsing/projection on each line. The user will be really annoyed
if they have to wait for 100 lines to be written to the log before
seeing new results!

I did some quick performance measurements with Criterion, and the
elapsed-time check takes about 16ns on my machine (Linux, 12900k). I
think the performance impact of checking that for every item will be
negligible.
2022-12-21 14:28:27 -08:00
Jakub Žádník
3a2c7900d6
Initial support for parse-time constants (#7436) 2022-12-22 00:21:03 +02:00
Stefan Holderbach
4e1f94026c
Add more input/output type annotations (#7532) 2022-12-21 20:20:46 +01:00
Stefan Holderbach
d27263af97
Bump to new development version 0.73.1 (#7544) 2022-12-21 12:35:50 -06:00
JT
1291b647ae
bump to 0.73 (#7542)
# Description

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

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

# User-Facing Changes

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

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2022-12-20 21:58:48 +13:00
Maxim Zhiburt
b01f50bd70
nu-explore/ Fix configuration issues (#7520)
close #7518

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-12-19 11:34:21 -06:00
raccmonteiro
5f48452e3b
some filesystem command signatures (#7464)
# Description

Signature for the following commands:

- `cd` 
- `cp` 
- `glob` 
- `ls` 
- `mkdir` 
- `mv` 
- `open`
- `rm`
- `save`
- `touch`

Related to https://github.com/nushell/nushell/issues/7320

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2022-12-19 13:40:57 +01:00
pwygab
dae1b9a996
prevent panic with format command (#7522)
Related: #7211.

Prevents numeric underflow in span.

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2022-12-19 13:10:02 +01:00
Reilly Wood
a21af0ade4
Revert "into cellpath command (#7417)" (#7523)
This reverts commit f0e93c2fa9 (PR #7417).

I'm currently [working on improving cell
paths](https://github.com/nushell/nushell/issues/7498#issuecomment-1356834798),
and I realized that I would need to make several improvements to `into
cellpath` along the lines of Jakub's comment here:
https://github.com/nushell/nushell/pull/7417#issuecomment-1345264955

I don't think `into cellpath` is quite ready for prime-time, and I'd
like to remove it before the upcoming release.
2022-12-18 23:02:18 -08:00
Maxim Zhiburt
28123841ba
Patch explore 4 (#7517)
ref #7339 - This PR updates explore to take some of the colors from
nushell, namely the line colors and the ls_colors.

note: Not sure why this regression appeared maybe it's a feature or it's
no longer supposed to be supported?

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2022-12-18 08:43:15 -06:00
Maxim Zhiburt
183be911d0
Patch after fix after fix 7380 (#7501)
> I'm not sure how i feel about that. I mean if there are a lot of
columns, it should probably have a max width so 1 column doesn't take
the entire width of your screen. Ideally it would work closely like
table worked before we migrated to tabled, as far as how column widths
were allocated.

I believe it still not completely matched.
*To be honest I am not against the #7446 approach.

The PR makes a switch between logics on a premise of `termwidth`.
So if `termwidth > 120` we start prioritizing amount of columns we can
show (We try to show as many columns as we can).
Otherwise we do what I've described in #7446 (We show the least columns
but with least truncation involvement).

In case it's OK,
I guess we could make the value configurable.

cc @fdncred 
ref #7446

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2022-12-17 16:16:32 -06:00
Reilly Wood
1966809502
explore tweaks Round 1 (#7511)
A few small tweaks to the new `explore` command:

1. Rewrote the help text a bit.
    1. I think it's important to mention `:try` up front.
2. Removed the info about `:help foo` because it's currently supported
by very few subcommands
2. Make `exit_esc` default to true. I want to avoid people getting stuck
in `explore` like they get stuck in Vim
3. ~~Always show the help message ("For help type :help") on startup~~
1. The message is small+unobtrusive and I don't this is worth a
configuration item
4. Exit the information view when Escape is pressed
5. General typo+grammar cleanup
    
cc: @zhiburt @fdncred
2022-12-17 12:05:41 -08:00
Jaffar Ashoor
c3c41a61b0
replace lazy_static with once_cell (#7502)
replacing the dependence on `lazy_static` with `once_cell`, this will
ensure that variables are initialized when needed instead of startup
time.
2022-12-17 10:30:04 -08:00
Leon
90849a067f
Fix encode base64 type signature and examples (#7515)
# Description

See title.

# User-Facing Changes

See title.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` 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.
2022-12-17 11:57:16 -06:00
Reilly Wood
705f12c1d9
Fix cell path when getting columns of non-records (#7508)
A follow-up to #7497. That change made it so that `get foo` would
eliminate non-record rows; I think that was an unintentional and
undesirable side-effect.

Before #7497:
```bash
〉[$nothing, { item: "foo" }] | get item
╭───┬─────╮
│ 0 │     │
│ 1 │ foo │
╰───┴─────╯
```
After #7497:
```bash
〉[$nothing, {item: "foo"}] | get item
╭───┬─────╮
│ 0 │ foo │
╰───┴─────╯
```

After this PR:
```bash
〉[$nothing, { item: "foo" }] | get item
╭───┬─────╮
│ 0 │     │
│ 1 │ foo │
╰───┴─────╯
```

cc: @merelymyself
2022-12-17 09:14:12 -08:00