Commit Graph

2188 Commits

Author SHA1 Message Date
Lucas Chaim
a03c1c266c
Add url decode command (#10611)
Implemented URL decoding as a url subcommand, created corresponding unit
tests. The logic, examples and descriptions were based on the existing
`url encode` command.

Resolves #10563

# Description
Added a new `url decode` command to compliment the existing `url
encode`, as proposed by myself in #10563.
It takes a string, list of strings or cell path and produces the
corresponding decoded strings.

![image](https://github.com/nushell/nushell/assets/4030336/815a34e9-7ceb-4d09-9d74-e700ba513b17)

# User-Facing Changes
New url subcommand `url decode`, as described above.

# Tests + Formatting
I've added unit tests for the new subcommand and ensured all actions
outlined below showed no issues.
- [x] `cargo fmt --all -- --check`
- [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used`
- [x] `cargo test --workspace`
- [x] `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"`
2023-10-05 18:43:58 +02:00
JT
8c507dc984
Revert "Port command examples to long option" (#10597)
Reverts nushell/nushell#10596

Using the long option in examples is going to be confusing as it makes
the reader think the long option is required. It also isn't idiomatic
Nushell.

The examples should be copy-paste-able as idiomatic Nushell, so as such
we shouldn't expand them to the long flag name.
2023-10-04 09:41:13 +13:00
Hofer-Julian
4a82ee6c11
Port command examples to long option (#10596)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description

Long options are preferable over short ones for documentation.
This PR ports some command examples to exclusively use long options.
<!--
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` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-10-03 13:41:41 -05:00
Stefan Holderbach
7c1487e18d
Use int type name consistently (#10579)
# Description
When referring to the type use `int` consistently. Only when referring
to the concept of integer numbers use `integer`.

- Fix `random integer` to `random int` tests
  - Forgot in #10520
- Use int instead of integer in error messages
- Use int type name in bits commands
- Fix messages in `for` examples
- Use int typename in `into` commands
- Use int typename in rest of commands
- Report errors in `nu-protocol` with int typename

Work for #10332 

# User-Facing Changes
User errorrs should now use `int` so you can easily find the necessary
commands or type annotations.

# Tests + Formatting
Only two tests found that needed updating
2023-10-03 18:24:32 +02:00
JT
844cb1213b
Remove cd w/ abbreviations (#10588)
# Description

This removes the old style "cd with abbreviations" that would attempt to
guess what directory you wanted to `cd` to. This would sometimes have
false positives, so we left it off by default in the config.

In the current main, we have much-improved path completions
(https://github.com/nushell/nushell/pull/10543) so you can now do `cd
a/b<tab>` and get a much better experience (because you can see the
directory you're about to cd to). This removes the need for the previous
abbreviation system.

# User-Facing Changes

This does remove the old abbreviation system. It will likely mean that
old config files that have settings for abbreviations will now get
errors.

update: here's an example of the error you'll see:


![image](https://github.com/nushell/nushell/assets/547158/6847a25d-895a-4b92-8251-278a57e8d29a)

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-10-03 10:51:46 +13:00
Jakub Žádník
eb6870cab5
Add --env and --wrapped flags to def (#10566) 2023-10-02 21:13:31 +03:00
Darren Schroeder
eeade99452
add a few more grid icons (#10583)
# Description

This PR adds a few more grid icons and updates some existing ones.

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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-10-02 10:04:58 -05:00
Marshall Bruner
679879f79b
Add warning to url join when input key is not supported (#10506) (#10565)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

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

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
Adds warning to `url join` when input key is not supported as suggested
by @amtoine in #10506.

It just adds a `println!` statement but it seems like that is all that
is done for other warnings, e.g.,
20aaaaf90c/crates/nu-glob/src/lib.rs (L434)

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->
All pass.
2023-10-02 06:47:02 -05:00
Hudson Clark
fa2e6e5d53
feat: Add unfold command (#10489)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

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

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
> [!NOTE]
> This PR description originally used examples where the `generator`
closure returned a list. It has since been updated to use records
instead.

The `unfold` command allows users to dynamically generate streams of
data. The stream is generated by repeatedly invoking a `generator`
closure. The `generator` closure accepts a single argument and returns a
record containing two optional keys: 'out' and 'next'. Each invocation,
the 'out' value, if present, is added to the stream. If a 'next' key is
present, it is used as the next argument to the closure, otherwise
generation stops.

The name "unfold" is borrowed from other functional-programming
languages. Whereas `fold` (or `reduce`) takes a stream of values and
outputs a single value, `unfold` takes a single value and outputs a
stream of values.

### Examples

A common example of using `unfold` is to generate a fibbonacci sequence.
See
[here](6ffdac103c/src/sources.rs (L65))
for an example of this in rust's `itertools`.

```nushell
> unfold [0, 1] {|fib| {out: $fib.0, next: [$fib.1, ($fib.0 + $fib.1)]} } | first 10
───┬────
 0 │  0
 1 │  1
 2 │  1
 3 │  2
 4 │  3
 5 │  5
 6 │  8
 7 │ 13
 8 │ 21
 9 │ 34
───┴────
```

This command is particularly useful when consuming paginated APIs, like
Github's. Previously, nushell users might use a loop and buffer
responses into a list, before returning all responses at once. However,
this behavior is not desirable if the result result is very large. Using
`unfold` avoids buffering and allows subsequent pipeline stages to use
the data concurrently, as it's being fetched.

#### Before
```nushell
mut pages = []
for page in 1.. {
  let resp = http get (
    {
      scheme: https,
      host: "api.github.com",
      path: "/repos/nushell/nushell/issues",
      params: {
	page: $page,
	per_page: $PAGE_SIZE
      }
    } | url join)

  $pages = ($pages | append $resp)

  if ($resp | length) < $PAGE_SIZE {
    break
  }
}
$pages
```

#### After
```nu
unfold 1 {|page|
  let resp = http get (
    {
      scheme: https,
      host: "api.github.com",
      path: "/repos/nushell/nushell/issues",
      params: {
	page: $page,
	per_page: $PAGE_SIZE
      }
    } | url join)

  if ($resp | length) < $PAGE_SIZE {
    {out: $resp}
  } else {
    {out: $resp, next: ($page + 1)}
  }
}
```


# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
- An `unfold` generator is added to the default context.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

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

Given the complexity of the `generator` closure's return value, it would
be good to document the semantics of `unfold` and provide some in-depth
examples showcasing what it can accomplish.
2023-09-30 09:08:06 -05:00
Ryan Armstrong
7eaa6d01ab
Add 'help escapes' command for quick reference of nushell string escapes (#10522)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

resolves #4869 

# 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.
-->
Adds a `help escape` command that can be used to display a table of
string escape sequences and their outputs.
```nu
help escapes
```
```nu
help escapes -h
```

The command should also appear in the list displayed when tab
autocompleting on `help`.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
Users can now use a new `help escapes` command to output a table of
string escape sequences and their outputs.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
Need to update docs to reflect existence of the new `help escapes`
command.
2023-09-30 09:04:27 -05:00
WindSoilder
d34581db4a
Rename: change the SyntaxShape of -c flag from list to record (#10526)
# Description
Fixes: #7085 
Also closes: #7526 

# User-Facing Changes
After this change, we need to use `-c` flag like this:
```nushell
[[a, b, c]; [1, 2, 3]] | rename -c { a: ham }
```
But we can rename many columns easily, here is another example:
```nushell
[[a, b, c]; [1, 2, 3]] | rename -c { a: ham, b: ham2 }
```
2023-09-30 08:59:47 -05:00
poketch
16453b6986
Making open case-insensitive to file extensions (#10451)
# Description

Closes #10441 

Uses `String::to_lowercase()` when the file's extension `ext` is parsed
to allow `from_decl(format!("from {ext}"))` to return the desired output
regardless of extension case.

It doesn't work with sqlite files since those are handled earlier in the
parsing but I think is good- since there's no standard file extension
used by sqlite so a user will likely want case sensitivity in that case.

This also has the (possibly undesired) effect of making `open`
completely case insensitive, e.g. `open foo.JSON` will work on a file
named `foo.json` and vice versa. This is good on Windows as it treats
`foo.json` and `foo.JSON` as the same file, but may not be the desired
behaviour on Unix.

If this behaviour is undesired I assume it would be fixed with a
`#[cfg(not(unix))]` attribute on the `to_lowercase()` operation but that
produces slightly "uglier" code that I didn't wish to submit unless
necessary. 

old behaviour:

![image](https://github.com/nushell/nushell/assets/79598494/261df577-e377-44ac-bef3-f6384bceaeb5)

new behaviour: 

![image](https://github.com/nushell/nushell/assets/79598494/04271740-a46f-4613-a3a6-1e220ef7f829)


# User-Facing Changes

`open` will now present a table when `open`-ing files with captitalized
extensions rather than the file's raw data

# Tests + Formatting

new test: `parses_file_with_uppercase_extension` which tests the desired
behaviour

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-09-29 17:20:59 +02:00
Stefan Holderbach
80a183dde2
Fix editor config for reedline and config nu/env (#10535)
# Description
This merges @horasal 's changes from #10246 and #10269

Closes #10205
Closes #8714

Fixes the bug that editor paths with spaces are unusable

Closes #10210 
Closes #10269


# User-Facing Changes
You can now either pass a string with the name of the executable or a
list with the executable and any flags to
`$env.config.buffer_editor`/`$env.EDITOR`/`$env.VISUAL`

Both the external buffer editor of reedline (by default bound to
`Ctrl-o`) and the commands `config nu` and `config env` will respect
those variables in the following order:
1. `$env.config.buffer_editor`
2. `$env.EDITOR`
3. `$env.VISUAL`

Example:
```
$env.EDITOR = "nvim"                      # The system-wide EDITOR is neovim
$env.config.buffer_editor = ["vim" "-p2"] # Force vim to open two tabs (not particularly useful)
$env.config.buffer_editor = null          # Unset `buffer_editor` -> Uses `$env.EDITOR` ergo nvim
```
# Tests + Formatting
None

---------

Co-authored-by: Horasal <1991933+horasal@users.noreply.github.com>
2023-09-29 16:36:03 +02:00
Bob Hyman
9a0c6f2e02
glob with ../ prefix now works; (#10504)
Fixes #10503 
Also improves link to metacharacter help;

# Description
`glob` code was using pattern as provided by user. If that had leading
`..\`, `wax::Glob` is documented to treat them as literal chars to be
matched.
Fix is to use `wax::Glob.partition()` to split such invariant prefixes
off the pattern and tack them onto the working directory computed
separately.

Before
```
> ls ..
╭───┬───────┬──────┬──────┬───────────────╮
│ # │ name  │ type │ size │   modified    │
├───┼───────┼──────┼──────┼───────────────┤
│ 0 │ ../r1 │ dir  │  7 B │ 3 hours ago   │
│ 1 │ ../r2 │ dir  │  3 B │ a day ago     │
│ 2 │ ../r3 │ dir  │ 13 B │ 4 minutes ago │
╰───┴───────┴──────┴──────┴───────────────╯
> glob ../r*
╭────────────╮
│ empty list │
╰────────────╯
```
After 
```
> glob ../r*
╭───┬──────────────────────────────╮
│ 0 │ /home/bobhy/src/rust/work/r2 │
│ 1 │ /home/bobhy/src/rust/work/r1 │
│ 2 │ /home/bobhy/src/rust/work/r3 │
╰───┴──────────────────────────────╯
```

# User-Facing Changes
None

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

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

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-09-29 06:48:55 -05:00
Stefan Holderbach
cc767463e6
Rename random integer to random int (#10520)
# Description
Consistently use `int` for types and commands

h/t @1kinoti

Work for #10332

# User-Facing Changes
Deprecate `random integer` in the next release

New command `random int`

# Tests + Formatting
(-)
2023-09-28 11:47:05 +02:00
fnuttens
8f4ea69c22
Add support for HTTP proxy in network commands (#10401)
Closes https://github.com/nushell/nushell/issues/8847

# Description

If the `HTTP_PROXY` variable is found, use its value to setup ureq
proxy. I haven't implemented `NO_PROXY` at the moment.

# User-Facing Changes

No breaking change for the user, the network commands simply use an
environment variable.

# Tests + Formatting

The existing tests seem to run fine, although I can't think of a new
test to add.
2023-09-27 15:43:34 +08:00
Stefan Holderbach
4a26719b0c
Bump dialoguer to 0.11.0 (#10510)
Includes fixes for breaking changes
Supersedes #10494
2023-09-26 18:00:16 +02:00
Antoine Stevan
feef612388
show the full directory / file path in "directory not found" error (#10430)
should close https://github.com/nushell/nushell/issues/10406

# Description
when writing a script, with variables you try to `ls` or `open`, you
will get a "directory not found" error but the variable won't be
expanded and you won't be able to see which one of the variable was the
issue...

this PR adds this information to the error.

# User-Facing Changes
let's define a variable
```nushell
let does_not_exist = "i_do_not_exist_in_the_current_directory"
```
### before
```nushell
> open $does_not_exist
Error: nu:🐚:directory_not_found

  × Directory not found
   ╭─[entry #7:1:1]
 1 │ open $does_not_exist
   ·      ───────┬───────
   ·             ╰── directory not found
   ╰────
```
```nushell
> ls $does_not_exist
Error: nu:🐚:directory_not_found

  × Directory not found
   ╭─[entry #8:1:1]
 1 │ ls $does_not_exist
   ·    ───────┬───────
   ·           ╰── directory not found
   ╰────
```

### after
```nushell
> open $does_not_exist
Error: nu:🐚:directory_not_found

  × Directory not found
   ╭─[entry #3:1:1]
 1 │ open $does_not_exist
   ·      ───────┬───────
   ·             ╰── directory not found
   ╰────
  help: /home/amtoine/documents/repos/github.com/amtoine/nushell/i_do_not_exist_in_the_current_directory does not exist
```
```nushell
> ls $does_not_exist
Error: nu:🐚:directory_not_found

  × Directory not found
   ╭─[entry #4:1:1]
 1 │ ls $does_not_exist
   ·    ───────┬───────
   ·           ╰── directory not found
   ╰────
  help: /home/amtoine/documents/repos/github.com/amtoine/nushell/i_do_not_exist_in_the_current_directory does not exist
```

# Tests + Formatting
shouldn't harm anything 🤞 

# After Submitting
2023-09-26 17:38:58 +08:00
Poliorcetics
a19cac2673
Command: Add config env/nu --default to print defaults (#10480)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

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

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

Closes #5436

When I opened this issue more than a year ago, I mainly wanted the
following capacity: easily access the full env and have the hability to
update it when a new version of `nushell` comes out.

With this PR I can now do the following:

```nu
source-env ~/.config/nushell/defaults/env.nu
source     ~/.config/nushell/defaults/config.nu

# Update nushell default config & env file (run this after a version update)
def update-defaults [] {
    config env --default | save -f ~/.config/nushell/defaults/env.nu
    config nu  --default | save -f ~/.config/nushell/defaults/config.nu
}
```

Which is more than enough for me. Along with `nushell` respecting the
XDG spec on macOS (`dirs-next` should be banned for CLI tools on macOS),
this should be one of the last hurdle before fully switching for me!

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

Two new switches to existing commands:

```nu
config env --default # Print the default env embedded at compile time in the binary
config nu  --default # Print the default config embedded at compile time in the binary
```

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

- Added a test for the output of `config env --default`
- Added a test for the output of `config nu --default`

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

Are the docs for commands generated automatically or do I need to make a
PR there too ? It's no problem if so, just point me at instructions if
there are any :)
2023-09-25 08:00:59 -05:00
Darren Schroeder
19cee5fda1
fix magenta_reverse and friends (#10491)
# Description

Magenta wasn't being interpreted correctly. note that `bg:
magenta_reverse attr: b` showed up as white. This was because it was
missing from the lookup and it was defaulting to white.

fixes #10490 

### Before

![image](https://github.com/nushell/nushell/assets/343840/0cf69ab8-813e-42e4-aea5-5db231f29f74)

### After

![image](https://github.com/nushell/nushell/assets/343840/d36f18f3-514d-443a-8bc8-cda2fed09615)


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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-24 14:43:17 -05:00
Stefan Holderbach
1bb953877e
Improve select row perf for large N (#10355)
# Description
While reviewing #10350 I noticed that a `HashSet<usize>` was used to
deduplicate the incoming rows, which are then sorted after cloning to a
separate `Vec`. This sounds like a candidate for a `BTreeSet` which
guarantees the ordering.

In the process I removed some dead code.

- Use `BTreeSet` instead of `HashSet`
- Remove dead `skip` logic
- Use `BTreeSet` directly in `NthIterator`
- Consume `BTreeSet` through `Peekable<IntoIter>`
2023-09-21 23:51:13 +02:00
George Padley
1c677c9577
Map DirectoryNotFound to FileNotFound for open command (#10089)
# Description


This PR should close #10085
Maps `DirectoryNotFound` errors to `FileNotFound`. All other errors are
left unchanged.

# User-Facing Changes

This means a user will see `FileNotFound` instead of `DirectoryNotFound`
which is more meaning full to the user.
2023-09-21 20:17:44 +02:00
Maxim Zhiburt
7cfd4d2cfa
nu-table: Add table option --abbreviated (#10399)
- Added `--abbreviated`/`-a` option
- Adedd `abbreviate_if_longer_than` config opt for it.

```nu
ls | table -a 3
```

```
╭───┬────────────────────┬──────┬───────────┬──────────────╮
│ # │        name        │ type │   size    │   modified   │
├───┼────────────────────┼──────┼───────────┼──────────────┤
│ 0 │ CODE_OF_CONDUCT.md │ file │   3.4 KiB │ 4 days ago   │
│ 1 │ CONTRIBUTING.md    │ file │  18.3 KiB │ 2 weeks ago  │
│ 2 │ Cargo.lock         │ file │ 144.3 KiB │ 15 hours ago │
│ 3 │ ...                │ ...  │ ...       │ ...          │
│ 4 │ tests              │ dir  │   4.0 KiB │ 4 months ago │
│ 5 │ toolkit.nu         │ file │  14.6 KiB │ 5 days ago   │
│ 6 │ wix                │ dir  │   4.0 KiB │ 2 months ago │
╰───┴────────────────────┴──────┴───────────┴──────────────╯
```

```nu
$env | table -a 3
```

```
╭──────────────────┬──────────────────────────────────────────────────────────────────────────╮
│ BROWSER          │ firefox                                                                  │
│ CARGO            │ /home/maxim/.rustup/toolchains/1.70.0-x86_64-unknown-linux-gnu/bin/cargo │
│ CARGO_HOME       │ /home/maxim/.cargo                                                       │
│ ...              │ ...                                                                      │
│ XDG_SESSION_TYPE │ x11                                                                      │
│ XDG_VTNR         │ 7                                                                        │
│ _                │ /home/maxim/.cargo/bin/cargo                                             │
╰──────────────────┴──────────────────────────────────────────────────────────────────────────╯
```

close #10393

PS: Maybe as a separate issue (good candidate for `GOOD FIRST ISSUE`)
add a config option to change a default `...` truncation sign to a
custom? (which would be applicable not only for `--abbreviated` but all
kind of tables)

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-09-20 12:59:08 -05:00
Darren Schroeder
4ae53d93fb
new command: into value (#10427)
# Description

This new command `into value` is a command that tries to infer the type
of data you have in a table. It converts each cell to a string and then
runs a set of regular expressions on that string. This was mostly
cobbled together after looking at how polars does similar things. The
regular expressions were taken straight form polars and tweaked.

### Before
```nushell
❯ [[col1 col2 col3 col4 col5 col6]; ["1" "two" "3.4" "true" "2023-08-10 14:07:17.922050800 -05:00" "2023-09-19"]] |
  update col1 {|r| $r.col1 | into int } |
  update col3 {|r| $r.col3 | into float } |
  update col4 {|r| $r.col4 | into bool } |
  update col5 {|r| $r.col5 | into datetime } |
  update col6 {|r| $r.col6 | into datetime }
╭#┬col1┬col2┬col3┬col4┬───col5────┬───col6────╮
│0│   1│two │3.40│true│a month ago│8 hours ago│
╰─┴────┴────┴────┴────┴───────────┴───────────╯
```
or
```nushell
❯ [[col1 col2 col3 col4 col5 col6]; ["1" "two" "3.4" "true" "2023-08-10 14:07:17.922050800 -05:00" "2023-09-19"]] |
  into int col1 |
  into float col3 |
  into bool col4 |
  into datetime col5 col6
╭#┬col1┬col2┬col3┬col4┬───col5────┬───col6────╮
│0│   1│two │3.40│true│a month ago│8 hours ago│
╰─┴────┴────┴────┴────┴───────────┴───────────╯
```

### After
```nushell
❯ [[col1 col2 col3 col4 col5 col6]; ["1" "two" "3.4" "true" "2023-08-10 14:07:17.922050800 -05:00" "2023-09-19"]] | into value
╭#┬col1┬col2┬col3┬col4┬───col5────┬───col6────╮
│0│   1│two │3.40│true│a month ago│8 hours ago│
╰─┴────┴────┴────┴────┴───────────┴───────────╯
```

It's definitely not perfect. There are ways it will fail because on
regular expressions not working on all formats. My hope is that people
will pick this up and add more regular expressions and if there are
problems with the existing ones, change them. This is meant as a
"starter command" with easy entry for newcomers that are looking to chip
in and help out.

Also, some tests probably need to be added to ensure what we have now
doesn't break with updates.

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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-20 12:57:58 -05:00
Darren Schroeder
29e809ad77
allow values command to support LazyRecords (#10418)
# Description

This PR allows the `values` command to support lazy records.

closes https://github.com/nushell/nushell/issues/10417

### Before
```nushell
sys | values
Error: nu:🐚:only_supports_this_input_type

  × Input type not supported.
   ╭─[entry #1:1:1]
 1 │ sys | values
   · ─┬─   ───┬──
   ·  │       ╰── only record or table input data is supported
   ·  ╰── input type: record<host: record<name: string, os_version: string, long_os_version: string, kernel_version: string, hostname: string, uptime: duration, boot_time: string, sessions: list<any>>, cpu: table<name: string, brand: string, freq: int, cpu_usage: float, load_average: string, vendor_id: string>, disks: table<device: string, type: string, mount: string, total: filesize, free: filesize, removable: bool, kind: string>, mem: record<total: filesize, free: filesize, used: filesize, available: filesize, swap total: filesize, swap free: filesize, swap used: filesize>, temp: list<any>, net: table<name: string, sent: filesize, recv: filesize>>
   ╰────
```

### After
```nushell
❯ sys | values
╭─┬─────────────────╮
│0│{record 8 fields}│
│1│[table 16 rows]  │
│2│[table 1 row]    │
│3│{record 7 fields}│
│4│[list 0 items]   │
│5│[table 5 rows]   │
╰─┴─────────────────╯
```

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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-20 12:57:29 -05:00
Antoine Stevan
f8939de14f
Remove str replace --string after deprecation (#10064)
related to
- https://github.com/nushell/nushell/pull/10038

# Description
`str replace --string` has been deprecated in
https://github.com/nushell/nushell/pull/10038 and should be removed
before 0.85.

this PR removes the `--string` option from `str replace` completely.

# User-Facing Changes
`str replace --string` will no longer work and will give an error
instead of a warning.
2023-09-19 15:54:20 +02:00
Darren Schroeder
a9a82de5c4
fix some new chrono warnings (#10384)
# Description

This PR cleans up some warnings on the latest chrono dependency.

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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-15 15:46:25 -05:00
J-Kappes
5ee74b6ab5
fix input --until-bytes: now stops at any of given bytes (#10235)
- this PR should close #10197

# Description
`input --bytes-until` takes a string but used to only terminate on the
first byte of that string. Now it checks for each byte in the string.

# User-Facing Changes
all of the above. No change in documentation needed. New behavior
arguably fits better.

# Tests + Formatting
don't know how to test input
2023-09-15 06:55:37 -05:00
WindSoilder
2c176a7f14
Ps: add cwd column on linux and macos (#10347)
# Description
Close:  #7484

Just found that I want `cwd` column on linux/macos as well..
2023-09-14 08:10:15 -05:00
Stefan Holderbach
bbf0b45c59
Update internal use of decimal to float (#10333)
# Description
We made the decision that our floating point type should be referred to
as `float` over `decimal`.
Commands were updated by #9979 and #10320

Now make the internal codebase consistent in referring to this data type
as `float`.

Work for #10332

# User-Facing Changes

`decimal` has been removed as a type name/symbol. 

Instead of 
```nushell
def foo [bar: decimal] decimal -> decimal {}
```
use 
```nushell
def foo [bar: float] float -> float {}
```

Potential effect of `SyntaxShape`'s `Display` implementation now also
referring to `float` instead of `decimal`

# Details
- Rename `SyntaxShape::Decimal` to `Float`
- Update `Display for SyntaxShape` to `float`
- Update error message + fn name in dataframe code
- Fix docs in command examples
- Rename tests that are float specific
- Update doccomment on `SyntaxShape`
- Update comment in script

# Tests + Formatting
Updates the names of some tests
2023-09-13 23:53:55 +02:00
Gonçalo Gomes
ce4ea16c08
fix #10319: allow json request of value type list (#10356)
# Description

this commit adds the handling of Value::List when BodyType is Json
it also adds the corresponding test (trying to send a list)

Fixes #10319

# User-Facing Changes

Added the ability to send a json list in the POST message

# Tests + Formatting
- [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`
to check that you're using the standard code style
- [x] `cargo test --workspace` to check that all tests pass (on Windows
make sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- [x] `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

Also ran `nc -l -p 8080` in other terminal and `http post -fe -t
application/json http://localhost:8080 [{ field: true }]` I see the
following appear in the output of nc:
```
POST / HTTP/1.1
Host: localhost:8080
User-Agent: nushell
Accept: */*
Content-Type: application/json
accept-encoding: gzip
Content-Length: 16

[{"field":true}]%
```
2023-09-13 16:54:03 +02:00
Tilen Gimpelj
bbea7da669
Remove select error if same row/column is provided (#10350)
This PR is in reference to #10215.

This PR changes `select` to work even if multiple equal items were
provided.
This would previously error, but now works
```nushell
let arg = [ 1 a ]
[[a b c]; [1 2 3] [4 5 6] [7 8 9]] 
| select $arg

```
# User-Facing Changes

Nothing too radical, just experience improvements. Users won't need to
pass the values through `unique` beforehand.
2023-09-13 13:49:55 +02:00
Stefan Holderbach
a14e9e0a2e
Invert &Options to Option<&T> (#10315)
Elide the reference for `Copy` type (`usize`)
Use the canonical deref where possible.
* `&Box` -> `&`
* `&String` -> `&str`
* `&PathBuf` -> `&Path`

Skips the ctrl-C handler for now.
2023-09-13 07:00:58 +08:00
Darren Schroeder
2a08865851
add a few more columns to linux ps -l output (#10344)
# Description

This PR tried to add a few more columns to the Linux `ps -l` command.
Those columns are:
* start_time
* user_id
* priority
* process_threads

There are a few that I left commented out that could be added but the
screen was beginning to look crowded. So, I left out:
* group_id
* session_id
* tgp_id (which could be helpful for eventual job control)

And there's like 100 more things that could be added that didn't seem
especially useful right now.


![image](https://github.com/nushell/nushell/assets/343840/065c0538-8f7d-4c9f-871f-a1bc98aff9d1)


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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-12 14:50:05 -05:00
Eugeen Sablin
9e1e2a4320
provide env to commands and try to start provided path (#10302)
fixes #8551

# Description
Use `open::commands` function to get list of command available for
starting given path. run commands directly, providing environment, until
one of them is successful.

example of output if start was not successful:
```
~\code\nushell> start ..\nustart\a.myext                                                                    09/12/2023 01:37:55 PM
Error: nu:🐚:external_command

  × External command failed
   ╭─[entry #1:1:1]
 1 │ start ..\nustart\a.myext
   ·       ─────────┬────────
   ·                ╰── No command found to start with this path
   ╰────
  help: Try different path or install appropriate command

        Command `cmd /c start "" "..\nustart\a.myext"` failed with exit code: 1
```

# User-Facing Changes
`start` command now provides environment to the external command. This
is how it worked in `nu 0.72`, see linked issue.

# Tests + Formatting
`start` command didn't have any tests and this PR does not add any.
Integration-level tests will require setup specific to OS and
potentially change global environment on testing machine. For unit-level
test it is possible to test `try_commands` function. But is still runs
external commands, and robust test will require apriori knowledge which
commands are necessary successful to run and which are not.
2023-09-12 14:03:41 +02:00
Stefan Holderbach
d53b0a99d0
Rename random decimal to random float (#10320)
# Description
Similar to #9979

# User-Facing Changes
`random decimal` will now raise a warning and can be removed in an
upcoming release.

New command is named `random float`

# Tests + Formatting
Tests updated and improved.
2023-09-12 13:03:05 +02:00
Stefan Holderbach
1fb4f9e455
Rename into decimal to into float (#9979)
# Description
We keep "into decimal" for a release and warn through a message that it
will be removed in 0.86.

All tests are updated to use `into float`

# User-Facing Changes
`into decimal` raises a deprecation warning, will be removed soon.
Use `into float` as the new functionally identical command instead.

```
~/nushell> 2 | into decimal
Error:   × Deprecated command
   ╭─[entry #1:1:1]
 1 │ 2 | into decimal
   ·     ──────┬─────
   ·           ╰── `into decimal` is deprecated and will be removed in 0.86.
   ╰────
  help: Use `into float` instead


2
```

# Tests + Formatting
Updated

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-09-12 13:02:47 +02:00
Stefan Holderbach
e90b099622
Use slices directly instead of &Vec (#10328)
Simplifies the signature, makes it more flexible.
Detected a few unnecessary allocations in the process.
2023-09-12 11:38:20 +08:00
JT
84c10de864
remove profiling from nushell's hot loop (#10325)
# Description

This removes pipeline element profiling. This could be a useful feature,
but pipeline elements are going to be the most sensitive to in terms of
performance, as `eval_block` and how pipelines are built is one of the
hot loops inside of the eval engine.

# User-Facing Changes

Removes pipeline element profiling.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-12 06:50:03 +12:00
Nano
7b89fab327
Keep order for par-each (#10249)
# Description
This PR adds new flag `--keep-order/-k` for the `par_each` filter. This
flag keeps sequence of output same as the order of input.

Output without the flag:
```nu
> 1..6 | par-each {|n| $n * 2 }
╭────╮
│  4 │
│ 10 │
│  2 │
│  8 │
│ 12 │
│  6 │
╰────╯
```

Output with the `--keep-order` flag:
```nu
> 1..6 | par-each --keep-order {|n| $n * 2 }
╭────╮
│  2 │
│  4 │
│  6 │
│  8 │
│ 10 │
│ 12 │
╰────╯
```

I think the presence of this flag is justified, since:
- Much easier to use than `.. | enumerate | par-each {|p| update item
..} | sort-by index | get item`
- Faster, as it uses internally parallel sorting in the same thread pool

A note about naming: it may conflict with `--keep-empty/-k` flag of the
`each` filter if the same feature will be used in `par-each`, so maybe
it needs some other name.
2023-09-11 06:42:09 -05:00
Stefan Holderbach
eddff46155
Bump calamine and fix clippy (#10314)
Upgrade calamine to 0.22
Reduces one potential dependency duplication

Supersedes #10305

Includes fixes for clippy lints as API changed to return owned data.
2023-09-11 12:39:52 +02:00
Stefan Holderbach
baa50ec9b2
Update crates-ci/typos and fix new typos (#10313)
Supersedes #10309
2023-09-11 12:37:06 +02:00
David Matos
ce378a68a6
Fix variables not allowed in ucp (#10304)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
Fixes #10300 , where using variables didnt work with `ucp` as it was
only expecting a `Expr::FilePath`.

Before: (from the issue)
```
❯ ucp -r $var $folder
Error:   × Missing file operand
   ╭─[entry #40:1:1]
 1 │ ucp -r $var $folder
   · ─┬─
   ·  ╰── Missing file operand
   ╰────
  help: Please provide source and destination paths
```
Now:
```
`ucp -r $var $folder`
# success
```

Also added the test to ensure its working:) . Oh, and I tweaked again
slightly the messages on two tests because now the whole `path` is
printed rather than `a`. Say:
```
#before
`cp a a` --> 'a' and 'a' are the same file 
# now
`cp a a` --> /home/current/location/a and /home/current/location/a are the same file
```
<!--
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:

- [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`
to check that you're using the standard code style
- [X] `cargo test --workspace` to check that all tests pass (on Windows
make sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- [X] `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library
<!--

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-10 17:54:33 -05:00
Antoine Stevan
fa40740e77
add case-insensitive example to where (#10299)
related to
-
https://discord.com/channels/601130461678272522/614593951969574961/1150395064292495400

# Description
two cool things about the `where` command
- it's versatile enough to allow creating a case-insensitive version of
itself
- it does not require the explicit use of a closure

this PR adds an example showing how to filter with `where` but
case-insensitively and without an explicite closure.

# User-Facing Changes
new example to `where`:
```nushell
  Find case-insensitively files called "readme", without an explicit closure
  > ls | where ($it.name | str downcase) =~ readme
```

# Tests + Formatting
the new example test above.

# After Submitting
2023-09-10 15:24:38 -05:00
Tilen Gimpelj
6811700b90
update reject to be able to recive arg list (#10216)
This PR is in relation to #10215 

# Description

This PR introduces `reject` to receive list of columns or rows as
argument.
This change is similar to change of `select` and the code used is
similar.

# User-Facing Changes
The user will be able to pass a list as rejection arguments.
```nushell
let arg = [ type size ]
[[name type size]; [ cargo.toml file 20mb ] [ Cargo.lock file 20mb] [src dir 100mb]] | reject $arg
```
2023-09-09 15:01:25 -05:00
Tilen Gimpelj
248aca7a44
reject multiple row args support (#10163)
# Description
This PR fixes `reject` failing when providing row items in ascending
order.


# User-Facing Changes
users can now `reject` multiple rows independently of each other.
```nushell
let foo = [[a b]; [ 1 2] [3 4] [ 5 6]]
# this will work independant of the order
print ($foo | reject 2 1)
print ($foo | reject 1 2)
```

---------

Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
2023-09-09 13:59:31 -05:00
Antoine Stevan
17abbdf6e0
allow into duration to take an integer amount of ns (#10286)
related to
-
https://discord.com/channels/601130461678272522/615329862395101194/1149717458786197524

# Description
because `1_234 | into datetime` takes an integer number of `ns` and
`1_234 | into filesize` takes an integer amount of bytes, i think `1_234
| into duration` should also be valid and see `1_234` as an integer
amount of `ns` 😋

# User-Facing Changes
## before
either
```nushell
1234 | into string | $in ++ "ns" | into duration
```
```nushell
1234 | $"($in)ns" | into duration
```
or
```nushell
1234 * 1ns
```
and
```nushell
> 1_234 | into duration
Error: nu::parser::input_type_mismatch

  × Command does not support int input.
   ╭─[entry #2:1:1]
 1 │ 1_234 | into duration
   ·         ──────┬──────
   ·               ╰── command doesn't support int input
   ╰────
```

## after
```nushell
> 1_234 | into duration
1µs 234ns
```

# Tests + Formatting
new example test
```rust
Example {
    description: "Convert a number of ns to duration",
    example: "1_234_567 | into duration",
    result: Some(Value::duration(1_234_567, span)),
}
```

# After Submitting
2023-09-09 13:49:08 -05:00
Darren Schroeder
40eca52ed5
allow update to use metadata (#10264)
# Description

This PR is an attempt to fix the `update` command so that it passes
along metadata. I'm not really sure I did this right, so please feel
free to point out where it's wrong.

The point is to be able to do something like this and have it respect
your LS_COLORS.
```
ls | update modified { format date }
```
### Before

![image](https://github.com/nushell/nushell/assets/343840/fc3eb207-4f6f-42b1-b5a4-87a1fe194399)

### After

![image](https://github.com/nushell/nushell/assets/343840/19d58443-7c88-4dd6-9532-1f45f615ac7b)


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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-09 13:47:42 -05:00
David Laban
8501024546
signpost 'input list --types [key]' from 'keybindings list' (#10287)
Supercedes https://github.com/nushell/nushell/pull/10196

# Description

After reading
https://github.com/nushell/nushell/pull/10196#issuecomment-1703986359 I
added a signpost from `keybindings listen` to `input listen`

When I initially tried `input listen` it always immediately returned
with:
```
╭───────┬────────╮
│ type  │ focus  │
│ event │ gained │
╰───────┴────────╯
```

I added an example to `input listen --help` to suggest only listening to
key events

Initially I also included a `result` but it prints as:

```
  ╭───────────┬───────────────╮
  │ type      │ key           │
  │ key_type  │ char          │
  │ code      │ c             │
  │ modifiers │ [list 1 item] │
  ╰───────────┴───────────────╯
```

rather than:

```
╭───────────┬───────────────────────────────╮
│ type      │ key                           │
│ key_type  │ char                          │
│ code      │ c                             │
│           │ ╭───┬───────────────────────╮ │
│ modifiers │ │ 0 │ keymodifiers(control) │ │
│           │ ╰───┴───────────────────────╯ │
╰───────────┴───────────────────────────────╯
```
so I removed it.

# User-Facing Changes

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

* Example describing how to use `input list --types [key]` to listen for
keybindings.
* Signpost pointing at `use std input; input list --types [key]` from
`keybindings list`.

## After merging

It is probably worth:

a) signposting to the keybindings section of the book from both of these
subcommands (like I did in
https://github.com/nushell/nushell/pull/10193),
b) giving an example in the book of how to take the output from `input
listen --types [key]` and format it for including in `config nu`
c) there are not currently any examples in
crates/nu-utils/src/sample_config/default_config.nu for keybindings with
multiple modifiers. Should I add alt+backspace-in-macos-vscode as an
example (gets translated to `{ modifier: control_alt keycode: char_h }`
for historical reasons)?

---------

Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
2023-09-09 09:42:37 -05:00
Darren Schroeder
2ffff959fc
add 6 more table themes (#10279)
# Description

After looking at a users terminal that didn't support UTF-8, I wanted to
add some themes that may help them. Here's what they look like.

## psql

![image](https://github.com/nushell/nushell/assets/343840/67ac003a-72f1-4e2b-8bb0-244b70385d59)

## markdown

![image](https://github.com/nushell/nushell/assets/343840/a8f4a439-013b-48ee-b9e0-284ec47d1eef)

## dots
please excuse the different theme

![image](https://github.com/nushell/nushell/assets/343840/fb931650-cc64-4f0a-bf3d-ec736e0374ad)

## restructured

![image](https://github.com/nushell/nushell/assets/343840/80595a8e-f2b3-49dc-ad02-81e94bde5253)

## ascii_rounded

![image](https://github.com/nushell/nushell/assets/343840/42f0b8b2-1fd2-4ae5-b28c-477e83ded354)

## basic_compact

![image](https://github.com/nushell/nushell/assets/343840/5888b6b2-b9b8-48bc-963e-5a76ef246adc)


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

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2023-09-08 16:34:36 -05:00