Commit graph

7497 commits

Author SHA1 Message Date
dependabot[bot]
4d0b6d8821
Bump pretty_assertions from 1.3.0 to 1.4.0 (#9781) 2023-07-24 05:41:03 +00:00
dependabot[bot]
b9acb61d9d
Bump tempfile from 3.6.0 to 3.7.0 (#9780) 2023-07-24 05:16:47 +00:00
Stefan Holderbach
2dcd1c5dbe
Abort type determination for List early (#9779)
# Description
If we reach the conclusion that the fields of a list are of `Type::Any`
there is no need to continue as the type will remain `Type::Any`

This should improve runtimes of `Value.get_type()` for lists with mixed
types.

# User-Facing Changes
None, a speedup in some cases.

# Tests + Formatting
Relies on existing tests
2023-07-24 07:15:53 +02:00
Stefan Holderbach
2aeb77bd3e
Fix output signature of split chars/words (#9739)
# Description
Those two commands did *not* vectorize over the input in the pure sense
as they performed a flat map. Now they return a list for each string
that gets split by them.

```
["foo" "bar"] | split chars
```

## Before 

```
╭───┬───╮
│ 0 │ f │
│ 1 │ o │
│ 2 │ o │
│ 3 │ b │
│ 4 │ a │
│ 5 │ r │
╰───┴───╯
```

## After
```
╭───┬───────────╮
│ 0 │ ╭───┬───╮ │
│   │ │ 0 │ f │ │
│   │ │ 1 │ o │ │
│   │ │ 2 │ o │ │
│   │ ╰───┴───╯ │
│ 1 │ ╭───┬───╮ │
│   │ │ 0 │ b │ │
│   │ │ 1 │ a │ │
│   │ │ 2 │ r │ │
│   │ ╰───┴───╯ │
╰───┴───────────╯
```
2023-07-23 17:06:41 -05:00
Stefan Holderbach
17f8ad7210
Use explicit in/out list types for vectorized commands (#9742)
# Description
All commands that declared `.vectorizes_over_list(true)` now also
explicitly declare the list form of their scalar types.

- Explicit in/out list signatures for nu-command
- Explicit in/out list signatures for nu-cmd-extra
- Add comments about cellpath behavior that is still unresolved


# User-Facing Changes
Our type signatures will now be more explicit about which commands
support vectorization over lists.
On the downside this is a bit more verbose and less systematic.
2023-07-23 20:46:53 +02:00
Stefan Holderbach
4dbdb1fe54
Add explicit input types for vectorized into int form (#9741)
# Description
Don't just use `List<Any>`, be precise for the vectorized form as well.

# User-Facing Changes
More explicit albeit verbose type information in the signature
2023-07-23 20:36:53 +02:00
Antoine Stevan
79359598db
add table -> table to into datetime (#9775)
should close https://github.com/nushell/nushell/issues/9774

# Description
given the help page of `into datetime`, 
```
Parameters:
  ...rest <cellpath>: for a data structure input, convert data at the given cell paths
```
it looks like `into datetime` should accept tables as input 🤔 

this PR
- adds the `table -> table` signature to `into datetime`
- adds a test to make sure the behaviour stays there
2023-07-23 20:14:51 +02:00
Vikrant A P
75180d07de
Fix: remove unnecessary r#"..."# (#8670) (#9764)
<!--
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.
-->
This PR is related to **Tests: clean up unnecessary use of cwd,
pipeline(), etc.
[#8670](https://github.com/nushell/nushell/issues/8670)**

- Removed the `r#"..."#` raw string literal syntax, which is unnecessary
when there are no special characters that need quoting from the tests
that use the `nu!` macro.
- `cwd:` and `pipeline()` has not changed


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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-21 17:32:37 +02:00
mengsuenyan
cdc4fb1011
fix #9653 the cmd detect columns with the flag -c (#9667)
fix `detect columns` with flag `-c, --combine-columns` run failed when
using some range

- fixes #9653 

fix #9653 the cmd detect columns with the flag -c, --combine-columns run
failed when using some range.

add unit test for the command `detect columns`

```text
Attempt to automatically split text into multiple columns.

Usage:
  > detect columns {flags} 

Flags:
  -h, --help - Display the help message for this command
  -s, --skip <Int> - number of rows to skip before detecting
  -n, --no-headers - don't detect headers
  -c, --combine-columns <Range> - columns to be combined; listed as a range

Signatures:
  <string> | detect columns -> <table>

Examples:
  Splits string across multiple columns
  > 'a b c' | detect columns -n
  ╭───┬─────────┬─────────┬─────────╮
  │ # │ column0 │ column1 │ column2 │
  ├───┼─────────┼─────────┼─────────┤
  │ 0 │ a       │ b       │ c       │
  ╰───┴─────────┴─────────┴─────────╯

  Splits a multi-line string into columns with headers detected
  > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns
  ╭───┬────┬────┬────┬────┬────╮
  │ # │ c1 │ c2 │ c3 │ c4 │ c5 │
  ├───┼────┼────┼────┼────┼────┤
  │ 0 │ a  │ b  │ c  │ d  │ e  │
  ╰───┴────┴────┴────┴────┴────╯

  
  > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c 0..1
  ╭───┬─────┬────┬────┬────╮
  │ # │ c1  │ c3 │ c4 │ c5 │
  ├───┼─────┼────┼────┼────┤
  │ 0 │ a b │ c  │ d  │ e  │
  ╰───┴─────┴────┴────┴────╯

  Splits a multi-line string into columns with headers detected
  > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c -2..-1
  ╭───┬────┬────┬────┬─────╮
  │ # │ c1 │ c2 │ c3 │ c4  │
  ├───┼────┼────┼────┼─────┤
  │ 0 │ a  │ b  │ c  │ d e │
  ╰───┴────┴────┴────┴─────╯

  Splits a multi-line string into columns with headers detected
  > $'c1 c2 c3 c4 c5(char nl)a b c d e' | detect columns -c 2..
  ╭───┬────┬────┬───────╮
  │ # │ c1 │ c2 │  c3   │
  ├───┼────┼────┼───────┤
  │ 0 │ a  │ b  │ c d e │
  ╰───┴────┴────┴───────╯

  Parse external ls command and combine columns for datetime
  > ^ls -lh | detect columns --no-headers --skip 1 --combine-columns 5..7

```
2023-07-21 08:25:06 -05:00
Ian Manske
7e1b922ea7
Add functions for each Value case (#9736)
# Description
This PR ensures functions exist to extract and create each and every
`Value` case. It also renames `Value::boolean` to `Value::bool` to match
`Value::test_bool`, `Value::as_bool`, and `Value::Bool`. Similarly,
`Value::as_integer` was renamed to `Value::as_int` to be consistent with
`Value::int`, `Value::test_int`, and `Value::Int`. These two renames can
be undone if necessary.

# User-Facing Changes
No user facing changes, but two public functions were renamed which may
affect downstream dependents.
2023-07-21 08:20:33 -05:00
Darren Schroeder
0b1e368cea
update history_isolation to false (#9763)
# Description

This PR follows #9762 and sets the rust component to match

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-21 06:58:32 -05:00
Darren Schroeder
3b9a0ac7c6
change the default of history.isolation (#9762)
# Description

This PR just fixes the default value of history.isolation and adds a few
more comments. isolation isn't available in plaintext so it should be
defaulted to off/false.

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-21 06:40:42 -05:00
Antoine Stevan
a1f989caf9
change the output of which to be more explicit (#9646)
related to
- https://github.com/nushell/nushell/issues/9637#issuecomment-1629387548

# Description
this PR changes the output of `which` from `table<arg: string, path:
string, built-in: bool> (stream)` to `table<command: string, path:
string, type: string> (stream)`.
- `command`: same as `arg` but more explicit name
- `path`: same as before, `null` when built-in
- `type`: instead of `buil-in: bool` says if it's a `built-in` a
`custom` command, an `alias` or an `external`

# User-Facing Changes
the output of `which` has changed

## some examples
```nushell
> which open
╭───┬─────────┬──────┬──────────╮
│ # │ command │ path │   type   │
├───┼─────────┼──────┼──────────┤
│ 0 │ open    │      │ built-in │
╰───┴─────────┴──────┴──────────╯
```
```nushell
> alias foo = print "foo"
> which foo
╭───┬─────────┬──────┬───────╮
│ # │ command │ path │ type  │
├───┼─────────┼──────┼───────┤
│ 0 │ foo     │      │ alias │
╰───┴─────────┴──────┴───────╯
```
```nushell
> def bar [] {}
> which bar
╭───┬─────────┬──────┬────────╮
│ # │ command │ path │  type  │
├───┼─────────┼──────┼────────┤
│ 0 │ bar     │      │ custom │
╰───┴─────────┴──────┴────────╯
```
```nushell
> which git
╭───┬─────────┬──────────────┬──────────╮
│ # │ command │     path     │   type   │
├───┼─────────┼──────────────┼──────────┤
│ 0 │ git     │ /usr/bin/git │ external │
╰───┴─────────┴──────────────┴──────────╯
```
```nushell
> which open git foo bar
╭───┬─────────┬──────────────┬──────────╮
│ # │ command │     path     │   type   │
├───┼─────────┼──────────────┼──────────┤
│ 0 │ open    │              │ built-in │
│ 1 │ git     │ /usr/bin/git │ external │
│ 2 │ foo     │              │ alias    │
│ 3 │ bar     │              │ custom   │
╰───┴─────────┴──────────────┴──────────╯
```

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

# After Submitting
mention that in the release note
2023-07-20 19:10:53 -05:00
A. Taha Baki
c01f2ee0e9
str-expand: new capability, empty collection item (#9750)
I added a new capability to `bracoxide` which is for `brace expansion`
(it's almost like bash brace expressions).

Anyway, this change adds this capability:

`A{,B,C} | str expand`, returns:

```md
- A
- AB
- AC
```


`A{B,,C} | str expand`, returns:

```md
- AB
- A
- AC
```

`A{B,C,} | str expand`, returns:

```md
- AB
- AC
- A
```

Updated examples, according to the new feature.
2023-07-20 18:51:25 -05:00
Antoine Stevan
693cb5c142
add any -> record to metadata (#9755)
# Description
in the help page of `metadata`, there is the following example
```nushell
ls | metadata
```
which gives the following error
```
Error: nu::parser::input_type_mismatch

  × Command does not support table input.
   ╭─[entry #2:1:1]
 1 │ ls | metadata
   ·      ────┬───
   ·          ╰── command doesn't support table input
   ╰────
```

this PR adds `any -> record` to the signatures of `metadata` to allow
the use of that kind of example.

# User-Facing Changes
`ls | metadata` will work again

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

# After Submitting
2023-07-21 07:11:20 +12:00
JT
d104efdf68
Fix capture logic for inner closures (#9754)
# Description

This fixes the variable capture logic for closures in two cases:

* Closures inside of closures did not properly register the closures (or
lack thereof) in the outer closure
* Closures which called their inner closures before definition did not
properly calculate the closures of the outer closure

Example of the first case:
```
do { let b = 3; def c [] { $b }; c }
```

Example of the second case (notice `c` is called before it is defined):
```
do { let b = 3; c; def c [] { $b }; c }
```

# User-Facing Changes
This should strictly allow closures to work more correctly.

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-21 07:10:54 +12:00
Alexandra Østermark
bd9d865912
fix removing symlinks on windows (#9704)
this PR should close #9624

# Description

Fixes the `rm` command assuming that a symlink is a directory and trying
to delete the directory as opposed to unlinking the symlink.

Should probably be tested on linux before merge.

Added tests for deleting symlinks
2023-07-20 20:16:03 +02:00
Darren Schroeder
c62cbcd5f8
handle sqlite tables better by surrounding with brackets (#9752)
# Description

This PR helps the sqlite handling better by surrounding table names with
brackets. This makes it easier to have table names with spaces like
`Basin / profile`.

Closes #9751 

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-20 11:20:56 -05:00
WindSoilder
ba4723cc9f
Support variables/interpolation in o>, e>, o+e> redirect (#9747)
# Description
Fixes:  #8517
Fixes: #9246
Fixes: #9709
Relative: #9723


## About the change
Before the pr, nushell only parse redirection target as a string(through
`parse_string` call).
In the pr, I'm trying to make the value more generic(using `parse_value`
with `SyntaxShape::Any`)

And during eval stage, we guard it to only eval `String`,
`StringInterpolation`, `FullCellPath`, `FilePath`, so other type of
redirection target like `1ms` won't be permitted.

# User-Facing Changes

After the pr: redirection support something like the following:
1. `let a = "x"; cat toolkit.nu o> $a`
2. `let a = "x"; cat toolkit.nu o> $"($a).txt"`
3. `cat toolkit.nu out> ("~/a.txt" | path expand)`
2023-07-20 13:56:46 +02:00
Darren Schroeder
488002f4bc
add range input to par-each (#9749)
# Description

Thie PR adds `Type::Range` input to `par-each` to allow `1..3 | do
something` again.
closes #9748 

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-20 06:48:18 -05:00
Michael Angerman
5115260366
add in a Readme for the crate nu-cmd-extra (#9745)
This outlines our plans for the commands located in the crate
nu-cmd-extra.

It also documents how one can build these commands from source.
2023-07-19 21:35:58 -07:00
Darren Schroeder
2d557bce5d
normalize default_config/env formatting (#9731)
# Description

This PR just tried to normalize the formatting. Everything should be 4
spaces now for those people that can't live with 2 spaces in the default
config files. I also remove some unneeded line breaks and changed two
places that should've been `edit` vs `send`.

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-19 06:49:21 -05:00
Ian Manske
17caa31325
nushell should be non-interactive if --testbin is supplied (#9730)
# Description
After #9693, tests will stop and go into the background if run locally
in bash, since nushell is being run in interactive mode even though
`--testbin` is supplied. This makes nushell run in non-interactive mode
if `--testbin` is supplied.
2023-07-19 00:02:09 +02:00
David Matos
1ba2269aa9
Disallow empty record with empty key,value pairs on ini format (#9722)
# Description
This PR fixes #9556. Now, only a section will be added if it contains a
key, value pair. With this change, `{record with 0 fields}`, should not
appear anymore.

For more context on empty sections, see issue on the
[crate](https://github.com/zonyitoo/rust-ini/issues/109)

```
open -r whatever | from ini
╭─────────────┬──────────────────────────────────────────────────────────────╮
│             │ ╭───────────────────────┬──────────────────────────────────╮ │
│ placeholder │ │ aws_access_key_id     │ AAAAAAAAAAAAAAAAAAAAA            │ │
│             │ │ aws_secret_access_key │ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB │ │
│             │ ╰───────────────────────┴──────────────────────────────────╯ │
│             │ ╭───────────────────────┬──────────────────────────╮         │
│ default     │ │ aws_access_key_id     │ AAAAAAAAAAAAAAAAAA       │         │
│             │ │ aws_secret_access_key │ AAAAAAAAAAAAAAAAAAAAAAA  │         │
│             │ │ aws_session_token     │ BBBBBBBBBBBBBBBBBBBBBBBB │         │
│             │ │ region                │ us-east-1                │         │
│             │ │ output                │ json                     │         │
│             │ ╰───────────────────────┴──────────────────────────╯         │
╰─────────────┴──────────────────────────────────────────────────────────────╯
```
# Tests + Formatting
Now test for exact `from ini` output

---------

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-07-18 22:14:18 +02:00
Stefan Holderbach
36030cab8a
Remove underused devdep getset (#9727)
# Description
We only used this procmacro crate in one place to generate two trivial
getters. Straightforward to replace. Should reduce test-compilation
requirements a bit.

# User-Facing Changes
None
2023-07-19 06:18:52 +12:00
Antoine Stevan
345c00aa1e
sync default config / env with default behaviour without any configuration (#9676)
related PRs and issues
- supersedes https://github.com/nushell/nushell/pull/9633
- should close https://github.com/nushell/nushell/issues/9630

# Description
this PR updates the `default_config.nu` config file and the `config.rs`
module in `nu_protocol` so that the default behaviour of Nushell,
without any config, and the one with `default_config.nu` and
`default_env.nu` are the same.

## changelog
- 3e2bfc9bb: copy the structure of `default_config.nu` inside the
implementation of `Default` in the `config.rs` module for easier check
of the default values
- e25e5ccd6: sync all the *simple* config fields, i.e. the
non-structured ones
- ae7e8111c: set the `display_output` hook to always run `table`
- a09a1c564: leave only the default menus => i've removed
`commands_menu`, `vars_menu` and `commands_with_description`

## todo
- [x] ~~check the defaults in `$env.config.explore`~~ done in 173bdbba5
and b9622084c
- [x] ~~check the defaults in `$env.config.color_config`~~ done in
c411d781d => the theme is now `{}` by default so that it's the same as
the default one with `--no-config`
- [x] ~~check the defaults `$env.config.keybindings`~~ done in 715a69797
- already available with the selected mode: `completion_previous`,
`next_page`, `undo_or_previous_page`, `yank`, `unix-line-discard` and
`kill-line`, e.g. in *vi* mode, `unlix-line-discard` is done in NORMAL
mode with either `d0` from the end of the line or `dd` from anywhere in
the line and `kill-line` is done in NORMAL mode with `shift + d`. these
bindings are available by default in *emacs* mode as well.
- previously with removed custom menus: `commands_menu`, `vars_menu` and
`commands_with_description`
- [x] ~~check `$env.config.datetime_format`~~ done in 0ced6b8ec => as
there is no *human* format for datetimes, i've commented out both
`$env.config.datetime_format` fields
- [x] ~~fix `default_env.nu`~~ done in 67c215011

# User-Facing Changes
this should not change anything, just make sure the default behaviour of
Nushell and the `default_config.nu` are in sync.

# Tests + Formatting
# After Submitting
2023-07-18 11:22:00 -05:00
nibon7
cc202e2199
Remove is-root crate (#9615)
# Description
This PR tries to remove `is-root` crate.

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

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

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

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-07-18 15:36:54 +02:00
Ian Manske
a5a79a7d95
Do not attempt to take control of terminal in non-interactive mode (#9693)
# Description
Fixes a regression from #9681 where nushell will attempt to place itself
into the background or take control of the terminal even in
non-interactive mode.

Using the same
[reference](https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html)
from #6584:

>A subshell that runs *interactively* has to ensure that it has been
placed in the foreground...

>A subshell that runs *non-interactively* cannot and should not support
job control.

`fish`
[code](54fa1ad6ec/src/reader.cpp (L4862))
also seems to follow this.

This *partially* fixes
[9026](https://github.com/nushell/nushell/issues/9026). That is, nushell
will no longer set the foreground process group in non-interactive mode.
2023-07-17 16:32:29 -05:00
Stefan Holderbach
656f707a0b
Clean up tests containing unnecessary cwd: tokens (#9692)
# Description
The working directory doesn't have to be set for those tests (or would
be the default anyways). When appropriate also remove calls to the
`pipeline()` function. In most places kept the diff minimal and only
removed the superfluous part to not pollute the blame view. With simpler
tests also simplified things to make them more readable overall (this
included removal of the raw string literal).

Work for #8670
2023-07-17 18:43:51 +02:00
dependabot[bot]
48271d8c3e
Bump miette from 5.9.0 to 5.10.0 (#9713) 2023-07-17 06:25:04 +00:00
dependabot[bot]
60bb984e6e
Bump strum_macros from 0.24.3 to 0.25.1 (#9714) 2023-07-17 06:23:17 +00:00
Darren Schroeder
eeb3b38fba
allow range as a input_output_type on filter (#9707)
# Description

This PR allows `Type::Range` on the `filter` command so you can do
things like this:
```nushell
❯ 9..17 | filter {|el| $el mod 2 != 0}
╭───┬────╮
│ 0 │  9 │
│ 1 │ 11 │
│ 2 │ 13 │
│ 3 │ 15 │
│ 4 │ 17 │
╰───┴────╯
```

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-16 08:13:46 -05:00
Antoine Stevan
79d9a0542f
allow into filesize to take tables as input / output (#9706)
# Description
i have the following command that should give a table of all the mounted
devices with information about their sizes, etc, etc... a glorified
output for the `df -h` command:
```nushell
def disk [] {
    df -h
      | str replace "Mounted on" "Mountpoint"
      | detect columns
      | rename filesystem size used avail used% mountpoint
      | into filesize size used avail
      | upsert used% {|it| 100 * (1 - $it.avail / $it.size)}
}
```

this should work given the first example of `into filesize`
```nushell
  Convert string to filesize in table
  > [[bytes]; ['5'] [3.2] [4] [2kb]] | into filesize bytes
```

## before this PR
it does not even parse
```nushell
Error: nu::parser::input_type_mismatch

  × Command does not support table input.
   ╭─[entry #1:5:1]
 5 │       | rename filesystem size used avail used% mountpoint
 6 │       | into filesize size used avail
   ·         ──────┬──────
   ·               ╰── command doesn't support table input
 7 │       | upsert used% {|it| 100 * (1 - $it.avail / $it.size)}
   ╰────
```

> **Note**
> this was working before the recent input / output type changes

## with this PR
it parses again and gives
```nushell
> disk | where mountpoint == "/" | into record
╭────────────┬───────────────────╮
│ filesystem │ /dev/sda2         │
│ size       │ 217.9 GiB         │
│ used       │ 158.3 GiB         │
│ avail      │ 48.4 GiB          │
│ used%      │ 77.77777777777779 │
│ mountpoint │ /                 │
╰────────────┴───────────────────╯
```

> **Note**
> the two following commands also work now and did not before the PR
> ```nushell
> ls | insert name_size {|it| $it.name | str length} | into filesize
name_size
> ```
> ```nushell
> [[device size]; ["/dev/sda1" 200] ["/dev/loop0" 50]] | into filesize
size
> ```

# User-Facing Changes
`into filesize` works back with tables and this effectively fixes the
doc.

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

this PR gives a `result` back to the first table example to make sure it
works fine.

# After Submitting
2023-07-16 08:04:35 -05:00
mike
5bfec20244
add match guards (#9621)
## description

this pr adds [match
guards](https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards)
to match patterns
```nushell
match $x {
   _ if $x starts-with 'nu' => {},
   $x => {}
}
```

these work pretty much like rust's match guards, with few limitations:

1. multiple matches using the `|` are not (yet?) supported
 
```nushell
match $num {
    0 | _ if (is-odd $num) => {},
    _ => {}
}
```

2. blocks cannot be used as guards, (yet?)

```nushell
match $num {
    $x if { $x ** $x == inf } => {},
     _ => {}
}
```

## checklist
- [x] syntax
- [x] syntax highlighting[^1]
- [x] semantics
- [x] tests
- [x] clean up

[^1]: defered for another pr
2023-07-16 12:25:12 +12:00
JT
57d96c09fa
fix input signature of let/mut (#9695)
# Description

This updates `let` and `mut` to allow for any input. This lets them
typecheck any collection they do.

For example, this now compiles:

```
def foo []: [int -> int, string -> int] {
  let x = $in
  if ($x | describe) == "int" { 3 } else { 4 }
}

100 | foo
```

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-15 19:41:48 +12:00
JT
b693db16cc
Revert "Fix SIGTTIN handling" (#9694)
Reverts nushell/nushell#9681

As mentioned in #9681 - this breaks running tests in wsl2.
2023-07-15 15:30:29 +12:00
Darren Schroeder
3ffafa7196
update rust toolchain to 1.69.0 (#9691)
# Description

This PR bumps the rust toolchain from 1.68.2 to 1.69.0 since 1.71.0 was
released 7/13/2023.

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-14 17:29:52 -05:00
JT
53ae03bd63
Custom command input/output types (#9690)
# Description

This adds input/output types to custom commands. These are input/output
pairs that related an input type to an output type.

For example (a single int-to-int input/output pair):

```
def foo []: int -> int { ... }
```

You can also have multiple input/output pairs:
```
def bar []: [int -> string, string -> list<string>] { ... }
```

These types are checked during definition time in the parser. If the
block does not match the type, the user will get a parser error.

This `:` to begin the input/output signatures should immediately follow
the argument signature as shown above.

The PR also improves type parsing by re-using the shape parser. The
shape parser is now the canonical way to parse types/shapes in user
code.

This PR also splits `extern` into `extern`/`extern-wrapped` because of
the parser limitation that a multi-span argument (which Signature now
is) can't precede an optional argument. `extern-wrapped` now takes the
required block that was previously optional.

# User-Facing Changes

The change to `extern` to split into `extern` and `extern-wrapped` is a
breaking change.

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-15 09:51:28 +12:00
Jakub Žádník
ba766de5d1
Refactor path commands (#9687) 2023-07-15 00:04:22 +03:00
JT
8c52b7a23a
Change input/output types in help to a table (#9686)
# Description

Updates `help` to more clearly show input/output types.

Before:


![image](https://github.com/nushell/nushell/assets/547158/5f11ca5c-54a0-414d-b3de-1a8b4dd7fcbd)

After:


![image](https://github.com/nushell/nushell/assets/547158/afc0eb1e-fad8-43b1-9382-c2a0d8e9334e)

# 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 -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-15 06:23:21 +12:00
Ian Manske
2fc9506bc7
Fix SIGTTIN handling (#9681)
# Description
Due to a typo? in the
[reference](https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html)
used to implement SIGTTIN handling, nushell will crash when being sent
to the background from within another shell.

For example, currently in bash:
```bash
$ nu -n &
[1] 176058
$ ERROR: failed to SIGTTIN ourselves

[1]+  Exit 1                  nu -n
$
```

Now fixed:
```bash
$ nu -n &
[1] 178788
$ jobs
[1]+  Stopped                 nu -n
$
```

For further reference, this is how
[fish](493cbeb84c/src/reader.cpp (L2571))
does it.

# User-Facing Changes
Bug fix only -- users should now be able to send nushell to the
background.
2023-07-15 06:15:48 +12:00
Darren Schroeder
4804e6a151
add more input_output_types found from breaking scripts (#9683)
# Description

This PR fixes some problems I found in scripts by adding some additional
input_output_types.

Here's a list of nushell scripts that it fixed. Look for `# broke here:`
below.

This PR fixes 3, 4, 6, 7 by adding additional input_output_types. 1 was
fixed by changing the script. 2. just doesn't work anymore because mkdir
return type has changed. 5, is a problem with the script, the datatype
for `...rest` needed to be removed.

```nushell
# 1.
def terminal-size [] {
    let sz = (input (ansi size) --bytes-until 'R')
    # $sz should look like this
    # Length: 9 (0x9) bytes | printable whitespace ascii_other non_ascii
    # 00000000:   1b 5b 33 38  3b 31 35 30  52                         •[38;150R
    let sz_len = ($sz | bytes length)

    # let's skip the esc[ and R
    let r = ($sz | bytes at 2..($sz_len - 2) | into string)

    # $r should look like 38;150
    # broke here: because $r needed to be a string for split row
    let size = ($r | split row ';')

    # output in record syntax
    {
        rows: ($size | get 0)
        columns: ($size | get 1)
    }
}

# 2.
# make and cd to a folder
def-env mkcd [name: path] {
    # broke here: but apparently doesn't work anymore
    # It looks like  mkdir returns nothing where it used to return a value
    cd (mkdir $name -v | first) 
}

# 3.
# changed 'into datetime'
def get-monday [] {
  (seq date -r --days 7 |
  # broke here: because into datetime didn't support list input
   into datetime | 
   where { |e| 
   ($e | date format %u) == "1" }).0 | 
   date format "%Y-%m-%d"
}

# 4.
# Delete all branches that are not in the excepts list
# Usage: del-branches [main]
def del-branches [
    excepts:list  # don't delete branch in the list
    --dry-run(-d) # do a dry-run
 ] {
    let branches = (git branch | lines | str trim)
    # broke here: because str replace didn't support list<string>
    let remote_branches = (git branch -r | lines | str replace '^.+?/' '' | uniq)
    if $dry_run {
        print "Starting Dry-Run"
    } else {
        print "Deleting for real"
    }
    $branches | each {|it|
        if ($it not-in $excepts) and ($it not-in $remote_branches) and (not ($it | str starts-with "*")) {
            # git branch -D $it
            if $dry_run {
                print $"git branch -D ($it)"
            } else {
                print $"Deleting ($it) for real"
                #git branch -D $it
            }
        }
    }
}

# 5.
# zoxide script
def-env __zoxide_z [...rest] {
  # `z -` does not work yet, see https://github.com/nushell/nushell/issues/4769
  # broke here: 'append doesn't support string input'
  let arg0 = ($rest | append '~').0
  # broke here: 'length doesn't support string input' so change `...rest:string` to `...rest`
  let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
    $arg0
  } else {
    (zoxide query --exclude $env.PWD -- $rest | str trim -r -c "\n")
  }
  cd $path
}

# 6.
def a [] { 
    let x = (commandline)
    if ($x | is-empty) { return }
    # broke here: because commandline was previously only returning Type::Nothing
    if not ($x | str starts-with "aaa") { print "bbb" }
}

# 7.
# repeat a string x amount of times
def repeat [arg: string, dupe: int] {
  # broke here: 'command does not support range input'
  0..<$dupe | reduce -f '' {|i acc| $acc + $arg}
}
```

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-14 10:58:41 -05:00
JT
786ba3bf91
Input output checking (#9680)
# Description

This PR tights input/output type-checking a bit more. There are a lot of
commands that don't have correct input/output types, so part of the
effort is updating them.

This PR now contains updates to commands that had wrong input/output
signatures. It doesn't add examples for these new signatures, but that
can be follow-up work.

# User-Facing Changes

BREAKING CHANGE BREAKING CHANGE

This work enforces many more checks on pipeline type correctness than
previous nushell versions. This strictness may uncover incompatibilities
in existing scripts or shortcomings in the type information for internal
commands.

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-14 15:20:35 +12:00
Jakub Žádník
e66139e6bb
Fix broken constants in scopes (#9679) 2023-07-14 00:02:05 +03:00
JT
30904bd095
Remove broken compile-time overload system (#9677)
# Description

This PR removes the compile-time overload system. Unfortunately, this
system never worked correctly because in a gradual type system where
types can be `Any`, you don't have enough information to correctly
resolve function calls with overloads. These resolutions must be done at
runtime, if they're supported.

That said, there's a bit of work that needs to go into resolving
input/output types (here overloads do not execute separate commands, but
the same command and each overload explains how each output type
corresponds to input types).

This PR also removes the type scope, which would give incorrect answers
in cases where multiple subexpressions were used in a pipeline.

# User-Facing Changes

Finishes removing compile-time overloads. These were only used in a few
places in the code base, but it's possible it may impact user code. I'll
mark this as breaking change so we can review.

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- -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-07-14 07:05:03 +12:00
Michael Angerman
99329f14a3
remove warning: unused import pipeline (#9675)
Fix a compiler warning caused by this file...

```rust
crates/nu-command/tests/commands/let_.rs
```
2023-07-13 09:12:20 -07:00
Michael Angerman
3c583c9a20
cratification: part III of the math commands to nu-cmd-extra (#9674)
The following math commands are being moved to nu-cmd-extra

* e (euler)
* exp
* ln

This should conclude moving the extra math commands as discussed in
yesterday's
core team meeting...

The remaining math commands will stay in nu-command (for now)....
2023-07-13 09:11:26 -07:00
WindSoilder
9a6a3a731e
support env and mut assignment with if block and match guard (#9650)
<!--
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.
-->
Fixes: https://github.com/nushell/nushell/issues/9595

So we can do the following in nushell:
```nushell
mut a = 3
$a = if 4 == 3 { 10 } else {20}
```
or
```nushell
$env.BUILD_EXT = match 3 { 1 => { 'yes!' }, _ => { 'no!' } }
```

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

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

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

---------

Co-authored-by: WindSoilder <windsoilder@DESKTOP-R8GRJ1D.localdomain>
2023-07-13 10:55:41 +02:00
Maxim Zhiburt
b2043135ed
nu-explore/ Add handlers for HOME/END keys (#9666)
close #9665

It could be good to run it though and see if it does what indented.
(I did but cause there's no test coverage for it it's better to recheck)

PS: Surely... this cursor logic much more complex then it shall be ...
the method names ....

cc: @fdncred

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-07-12 14:13:35 -05:00
Antoine Stevan
545697c0b2
simplify the test for let core command (#9671)
related to
- follow-up of https://github.com/nushell/nushell/pull/9658
- addressed part of https://github.com/nushell/nushell/issues/8670

# Description
removes useless `cwd` and `pipeline()` from the tests of `let`.

# User-Facing Changes
# Tests + Formatting
# After Submitting
2023-07-12 19:33:25 +02:00