Commit Graph

7543 Commits

Author SHA1 Message Date
WindSoilder
14bf25da14
rename from date format to format date (#9902)
# Description
Closes: #9891
I also think it's good to keep command name consistency.

And moving `date format` to deprecated.

# User-Facing Changes
Running `date format` will lead to deprecate message:
```nushell
❯ "2021-10-22 20:00:12 +01:00" | date format
Error: nu:🐚:deprecated_command

  × Deprecated command date format
   ╭─[entry #28:1:1]
 1 │ "2021-10-22 20:00:12 +01:00" | date format
   ·                                ─────┬─────
   ·                                     ╰── 'date format' is deprecated. Please use 'format date' instead.
   ╰────
```
2023-08-04 06:06:00 +12:00
Darren Schroeder
a455e2e5eb
remove vectorize_over_list from python plugin (#9905)
# Description

This PR brings our python plugin example inline with our new signature
by removing `vectorize_over_list` from the plugin.
2023-08-03 16:46:48 +02:00
JT
840b4b854b
Simplify default style and match Rust code to config (#9900)
# Description

This PR aligns the default config in the Rust code to the default config
in the nushell file.

To do so, it removes closures from the default file, opting instead to
pick a simple style as default. This allows easier maintenance of both
Rust and Nushell code without removing the ability to use closures for
styling in your configuration.

The default theme is now "dark mode" in both the Rust and nushell config
code.

Obligatory screenshot:


![image](https://github.com/nushell/nushell/assets/547158/233b11af-3b81-4513-8a69-3e7b1cac3865)


# 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-08-03 08:06:51 +12:00
Darren Schroeder
ec4941c8ac
update format signature to allow record to be passed in (#9898)
# Description

This PR updates the signature of `format` to allow records to be passed
in.

Closes #9897 

### Before
```nushell
{name: Downloads} | format "{name}"

  × Command does not support record<name: string> input.
   ╭─[entry #12:1:1]
 1 │ {name: Downloads} | format "{name}"
   ·                       ───┬──
   ·                          ╰── command doesn't support record<name: string> input
   ╰────
```

### After
```nushell
{name: Downloads} | format "{name}"
Downloads
```

# 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-08-02 10:57:58 -05:00
Darren Schroeder
dd86f14a5a
update items signature to allow any output (#9896)
# Description

This PR updates the `items` command to allow `any` output. items takes a
closure so theoretically, any value type of output could be valid.

### Before
```nushell
{a: 1 b: 2} | items {|k,v| {key: $k value: $v}} | transpose
Error: nu::parser::input_type_mismatch

  × Command does not support list<string> input.
   ╭─[entry #2:1:1]
 1 │ {a: 1 b: 2} | items {|k,v| {key: $k value: $v}} | transpose
   ·                                                   ────┬────
   ·                                                       ╰── command doesn't support list<string> input
   ╰────
```

### After
```nushell
❯ {a: 1 b: 2} | items {|k,v| {key: $k value: $v}} | transpose
╭───┬─────────┬─────────┬─────────╮
│ # │ column0 │ column1 │ column2 │
├───┼─────────┼─────────┼─────────┤
│ 0 │ key     │ a       │ b       │
│ 1 │ value   │       1 │       2 │
╰───┴─────────┴─────────┴─────────╯
```
# 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-08-02 08:42:26 -05:00
Darren Schroeder
63103580d2
update char signature with Table (#9895)
# Description

This PR updates the `char` command to allow `Table` output due to the
`--list` parameter.

### Before
```nushell
char --list | transpose
Error: nu::parser::input_type_mismatch

  × Command does not support string input.
   ╭─[entry #6:1:1]
 1 │ char --list | transpose
   ·               ────┬────
   ·                   ╰── command doesn't support string input
   ╰────
```

### After
```nushell
❯ char --list | transpose
╭───┬───────────┬─────────┬─────────┬─────────┬───────────┬─────────┬─────────────┬─────────┬─────────┬─────────┬──────────┬──────────┬──────────┬────────────┬──────────┬─────────────┬──────────┬────────────┬──────────┬──────────┬─────╮
│ # │  column0  │ column1 │ column2 │ column3 │  column4  │ column5 │   column6   │ column7 │ column8 │ column9 │ column10 │ column11 │ column12 │  column13  │ column14 │  column15   │ column16 │  column17  │ column18 │ column19 │ ... │
├───┼───────────┼─────────┼─────────┼─────────┼───────────┼─────────┼─────────────┼─────────┼─────────┼─────────┼──────────┼──────────┼──────────┼────────────┼──────────┼─────────────┼──────────┼────────────┼──────────┼──────────┼─────┤
│ 0 │ name      │ newline │ enter   │ nl      │ line_feed │ lf      │ carriage_re │ cr      │ crlf    │ tab     │ sp       │ space    │ pipe     │ left_brace │ lbrace   │ right_brace │ rbrace   │ left_paren │ lp       │ lparen   │ ... │
│   │           │         │         │         │           │         │ turn        │         │         │         │          │          │          │            │          │             │          │            │          │          │     │
│ 1 │ character │         │         │         │           │         │             │         │         │         │          │          │ |        │ {          │ {        │ }           │ }        │ (          │ (        │ (        │ ... │
│   │           │         │         │         │           │         │             │         │         │         │          │          │          │            │          │             │          │            │          │          │     │
│ 2 │ unicode   │ a       │ a       │ a       │ a         │ a       │ d           │ d       │ d a     │ 9       │ 20       │ 20       │ 7c       │ 7b         │ 7b       │ 7d          │ 7d       │ 28         │ 28       │ 28       │ ... │
╰───┴───────────┴─────────┴─────────┴─────────┴───────────┴─────────┴─────────────┴─────────┴─────────┴─────────┴──────────┴──────────┴──────────┴────────────┴──────────┴─────────────┴──────────┴────────────┴──────────┴──────────┴─────╯
```

# 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-08-02 08:42:13 -05:00
JT
d25df9c00b
Revert 9693 to prevent CPU hangs (#9893)
# Description

This reverts #9693 as it lead to CPU hangs. (btw, did the revert by hand
as it couldn't be done automatically. Hopefully I didn't miss anything 😅
)

Fixes #9859

cc @IanManske 

# 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-08-02 11:24:28 +12:00
Darren Schroeder
778a00efa1
update to current reedline (#9877)
# Description

This PR updates nushell to use the latest reedline. I swear that was the
only change I made. The other reordering stuff is by my vscode extension
I guess.

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

# 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-08-01 15:30:31 -05:00
mengsuenyan
fea822792f
Fixed the panic when type a statement similar to let f = 'f' $ in the nushell (#9851)
- this PR should close #9596 
- fixes #9596 
- this PR should close #9826 
- fixes #9826 

fixed the following bugs:
```nu
# type following statements in the nushell
let f = 'f' $;
mut f = 'f' $;
const f = 'f' $;

# then remove variable f, it will panics
let = 'f' $;
mut  = 'f' $;
const = 'f' $;
```
2023-08-02 04:21:40 +12:00
WindSoilder
f6033ac5af
Module: support defining const and use const variables inside of function (#9773)
<!--
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.
-->
Relative: #8248 

After this pr, user can define const variable inside a module.

![image](https://github.com/nushell/nushell/assets/22256154/e3e03e56-c4b5-4144-a944-d1b20bec1cbd)

And user can export const variables, the following screenshot shows how
it works (it follows
https://github.com/nushell/nushell/issues/8248#issuecomment-1637442612):

![image](https://github.com/nushell/nushell/assets/22256154/b2c14760-3f27-41cc-af77-af70a4367f2a)

## About the change
1. To make module support const, we need to change `parse_module_block`
to support `const` keyword.
2. To suport export `const`, we need to make module tracking variables,
so we add `variables` attribute to `Module`
3. During eval, the const variable may not exists in `stack`, because we
don't eval `const` when we define a module, so we need to find variables
which are already registered in `engine_state`

## One more thing to note about the const value.
Consider the following code
```
module foo { const b = 3; export def bar [] { $b } }
use foo bar
const b = 4;
bar
```
The result will be 3 (which is defined in module) rather than 4. I think
it's expected behavior.

It's something like [dynamic
binding](https://www.gnu.org/software/emacs/manual/html_node/elisp/Dynamic-Binding-Tips.html)
vs [lexical
binding](https://www.gnu.org/software/emacs/manual/html_node/elisp/Lexical-Binding.html)
in lisp like language, and lexical binding should be right behavior
which generates more predicable result, and it doesn't introduce really
subtle bugs in nushell code.

What if user want dynamic-binding?(For example: the example code returns
`4`)
There is no way to do this, user should consider passing the value as
argument to custom command rather than const.

## TODO
- [X] adding tests for the feature.
- [X] support export const out of module to use.

# 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-08-01 07:09:52 +08:00
Ian Manske
583ef8674e
Replace &Span with Span since Span is Copy (#9770)
# Description
`Span` is `Copy`, so we probably should not be passing references of
`Span` around. This PR replaces all instances of `&Span` with `Span`,
copying spans where necessary.

# User-Facing Changes
This alters some public functions to take `Span` instead of `&Span` as
input. Namely, `EngineState::get_span_contents`,
`nu_protocol::extract_value`, a bunch of the math commands, and
`Gstat::gstat`.
2023-07-31 21:47:46 +02:00
A. Taha Baki
94bec72079
str-expand: add path flag (#9856)
Related issues: #9838

Changes:

- added `--path` flag, for ease of use if the piped data is Path
(replaces all backslashes with double backslashes)
2023-07-31 07:48:29 -05:00
mengsuenyan
28ed21864d
fixed the bug ~ | path type return empty string (#9853)
- this PR should close #9849 
- fixes #9849
2023-07-31 07:47:18 -05:00
A. Taha Baki
e16ce1df36
str-expand: Add Escaping Example (#9841)
**Related Issue: #9838**

Adds an **example**, how bracoxide/str-expand handles the escaping char
`\`.
2023-07-31 07:45:39 -05:00
Jack Wright
87abfee268
Merged overloaded commands (#9860)
- fixes #9807

# Description

This pull request merges all overloaded dfr commands into one command:

eager:
dfr first -> eager/first.rs
dfr last -> eager/last.rs
dfr into-nu -> eager/to_nu.rs (merged)

lazy:
dfr min -> expressions/expressions_macro.rs lazy_expressions_macro
dfr max -> expressions/expressions_macro.rs lazy_expressions_macro
dfr sum -> expressions/expressions_macro.rs lazy_expressions_macro
dfr mean -> expressions/expressions_macro.rs lazy_expressions_macro
dfr std -> expressions/expressions_macro.rs lazy_expressions_macro
dfr var   -> expressions/expressions_macro.rs lazy_expressions_macro

series:
dfr n-unique -> series/n_unique.rs
dfr is-not-null -> series/masks/is_not_null.rs
dfr is-null -> series/masks/is_null.rs

# User-Facing Changes
No user facing changes

---------

Co-authored-by: Jack Wright <jack.wright@disqo.com>
2023-07-31 07:34:12 -05:00
Han Junghyuk
ba0f069c31
Turn bare URLs into cliclable links (#9854)
This PR adds angle brackets to URLs, making them clickable when reading
documentation.
2023-07-30 22:50:25 +02:00
jflics6460
154856066f
Accept records for http subcommand headers (-H) (#9771)
# Description

See also: #9743 
Before: 
`http <subcommand> -H` took a list in the form:

```nushell
[my-header-key-A my-header-value-A my-header-key-B my-header-value-B]
```

Now:
In addition to the old format, Records can be passed, For example,
```nushell
> let reqHeaders = {
    Cookie:  "acc=barfoo",
    User-Agent: "Mozilla/7.0 (Windows NT 33.0; Win64; x64) AppleWebKit/1038.90 (KHTML, like Gecko)"
}
> http get -H $reqHeaders https://example.com
```

is now equivalent to
```nushell
http get -H [Cookie "acc=barfoo" User-Agent "Mozilla/7.0 (Windows NT 33.0; Win64; x64) AppleWebKit/1038.90 (KHTML, like Gecko)"] https://example.com
```

# User-Facing Changes
No breaking changes, but Records can now also be passed to `http
<subcommand> -H`.

# Tests + Formatting
# After Submitting
2023-07-30 22:28:48 +02:00
Stefan Holderbach
f91713b714
Add format duration to replace into duration --convert (#9788)
# Description
Add `format duration` cmd to choose output unit.

This takes the previous `into duration --convert ...` behavior which
returned a string into its own `format duration` command.
This was suprising and not fitting with the general type signature for
the `into ...` commands.

This command for now lives in the `nu-cmd-extra` nursery.

# User-Facing Changes
## Breaking change
Removes formatting behavior from `into duration`
Now use `format duration` instead of `into duration --convert`
## Usage:
```
1sec | format duration us # Output data in microseconds
"2ms" | into duration | format duration sec # go from string to string
```


# Tests + Formatting
Basic example testing (including basic broadcast)
2023-07-30 22:23:36 +02:00
Stefan Holderbach
f1bf485b2a
Update unicode-linebreak to 0.1.5 (#9814)
# Description
This deduplicates `ahash` as it was previously an outdated
build-dependency of `unicode-linebreak`

Should provide a small benefit to initial from scratch compile.


# User-Facing Changes
None
2023-07-30 22:17:36 +02:00
Darren Schroeder
955de76116
bump to dev version 0.83.2 (#9866)
# Description

This PR bumps the development version of nushell to version 0.83.2.
2023-07-30 22:16:57 +02:00
Jack Wright
bf5bd3ff10
"merging into one dfr into-nu command" (#9858)
- fixes #9806

# Description

Merges ExprAsNu command and ToNu into one command. 

# User-Facing Changes

As both commands were overloading ```dfr into-nu``` there are no user
facing changes

---------

Co-authored-by: Jack Wright <jack.wright@disqo.com>
2023-07-29 15:23:31 -05:00
Stefan Holderbach
6ac3351fd1
Fix signature for math mode (#9846)
This command will always return a list, either because there are
multiple entries with the same frequency or just one.

It's implementation doesn't care about the composition of types as long
as they are number like, can be heterogeneous, will report
independently.

Work for #9812
2023-07-28 23:53:36 +02:00
Stefan Holderbach
b6dafa6e67
Fix math log signature (#9845)
While we are at it also fix `math log` to a more narrow type.

This supersedes part of #9740
2023-07-28 23:47:00 +02:00
Stefan Holderbach
152a541696
Fix signature for math sum (#9847)
This also supports filesize and duration.
Filesize is actually used for a non-running example

Work for #9812
2023-07-28 23:34:47 +02:00
Stefan Holderbach
ff8c3aa356
Fix signature for math abs (#9844)
This only supports number or duration

Make sure duration still works with the stricter type system

Work for #9812
2023-07-28 23:32:59 +02:00
Stefan Holderbach
99ed8e42a3
Fix type signature of median (#9843)
Still support forming the median over homogeneous lists of `Duration` or
`Filesize`. Don't advertise `list<any>` as this can become funky when
given an even number of elements...

Work for #9812
2023-07-28 23:32:26 +02:00
Stefan Holderbach
6a7a23e3fa
Fix math min/max signatures (#9830)
# Description
Under the hood those are just `Value::partial_cmp` and this is defined
for all values and defines a partial order over `any`

Should address part of https://github.com/nushell/nushell/issues/9813

# User-Facing Changes
Reenable all behavior before `0.83`

# Tests + Formatting
Added an example to `math min` showing this cursedness
2023-07-28 15:12:58 -05:00
JT
9448225690
Fix transpose input/output types (#9842)
# Description

As the typechecker doesn't currently support having the same input type
but two different output types, collapse the `transpose` input/output
signatures for now so that we don't mistakenly think that when given a
`table` a `table is always returned.

fixes https://github.com/nushell/nushell/issues/9710

# 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-29 06:23:17 +12:00
Stefan Holderbach
28b99bfaf7
Narrow signature of math ceil/floor (#9836)
# Description
More narrow attempt than #9740
This doesn't cause issues with the current `test_examples`
infrastructure.
But allows the output of those clearly integer producing commands to be
used with functions declaring `list<int>` or `int`

# User-Facing Changes
see above

# Tests + Formatting
None
2023-07-28 12:31:48 -05:00
Antoine Stevan
8403fff345
allow print to take data as input again (#9823)
related to
https://discord.com/channels/601130461678272522/601130461678272524/1134079115134251129

# Description
before 0.83.0, `print` used to allow piping data into it, e.g.
```nushell
"foo" | print
```
instead of 
```nushell
print "foo"
```

this PR enables the `any -> nothing` input / output type to allow this
again.

i've double checked and `print` is essentially the following snippet
```rust
        if !args.is_empty() {
            for arg in args {
                arg.into_pipeline_data()
                    .print(engine_state, stack, no_newline, to_stderr)?;
            }
        } else if !input.is_nothing() {
            input.print(engine_state, stack, no_newline, to_stderr)?;
        }
```
1. the first part is for `print a b c`
2. the second part is for `"foo" | print`

# User-Facing Changes
```nushell
"foo" | print
```
works again

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

# After Submitting

---------

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-07-27 21:40:25 +02:00
Antoine Stevan
aa08e81370
change signature of enumerate to any -> table (#9822)
related to
https://discord.com/channels/601130461678272522/1134054657086464072

# Description
the `enumerate` command always returns a table but its signature is `any
-> any` which can be confusing 😕
this PR changes the signature to `any -> table`

i've double checked and the source of `enumerate` returns a list of
records, a.k.a. a table 👌

# User-Facing Changes
this shouldn't change anything apart from the help page of `enumerate`
showing now
```
Input/output types:
  ╭───┬───────┬────────╮
  │ # │ input │ output │
  ├───┼───────┼────────┤
  │ 0 │ any   │ table  │
  ╰───┴───────┴────────╯
```
instead of 
```
Input/output types:
  ╭───┬───────┬────────╮
  │ # │ input │ output │
  ├───┼───────┼────────┤
  │ 0 │ any   │ any    │
  ╰───┴───────┴────────╯
```

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

# After Submitting
2023-07-27 21:39:03 +02:00
Stefan Holderbach
831d1da256
Bump trash in lockfile due to yank (#9824)
The previous version has been yanked.
To make sure `cargo install --locked` will pass.
2023-07-27 21:32:39 +02:00
Stefan Holderbach
3481c7e242
Fix signature of split row (#9829)
# Description
This command also flat-maps and doesn't create a table like `split
column`

We should probably reconsider the flatmap behavior like in #9739
but for the #9812 hotfix this is an unwelcome breaking change.

# User-Facing Changes
None

# Tests + Formatting
- Fix signature of `split row`
- Add test for output signature
2023-07-27 21:32:25 +02:00
JT
78e29af423
Fix prepend type, fix typos (#9828)
# Description

This PR does two (somewhat related) things:

* Fixes the `prepend` signature in the same way we fixed `append`
* Fixes a few typos in the examples of `prepend` and `append`

# 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-28 06:52:45 +12:00
JT
3ef5e90b64
Fix the implied collect type to 'any' (#9827)
# Description

Previously, we had a bug slip in about implied collection caused by
`$in`, that this output type would be of type `string`.

The type system fixes in 0.83 now make this more visible and cause
issues. This PR changes the output of the implied collection to `any`.
At some point in the future, we may want to carry the type through where
we can, but `any` should unblock using `$in`.

fixes #9825

# 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-28 06:26:28 +12:00
WindSoilder
6aa30132aa
fix append signature (#9821)
# Description
Fixes: #9720
Actually it mainly address the comment:
https://github.com/nushell/nushell/issues/9720#issuecomment-1652240104

After looking into example, I think if it receives a string, it should
returns a list too rather than a string
2023-07-27 15:53:48 +02:00
Darren Schroeder
5d2ef0faf1
add input_output_type to ansi command (#9817)
# Description

This PR fixes this not working `ansi --list | columns`. I originally
thought that this was a problem with `columns` but it turned out to be a
problem with the input output type of `ansi`. Since `ansi` was only
allowed to return strings, `columns` thought it was getting a string,
but it was a table.

closes #9808

tracking #9812

# 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-26 16:39:24 -05:00
Stefan Holderbach
b2e191f836
Remove Signature.vectorizes_over_list entirely (#9777)
# Description
With the current typechecking logic this property has no effect.
It was only used in the example testing, and provided some indication of
this vectorizing property.
With #9742 all commands that previously declared it have explicit list
signatures. If we want to get it back in the future we can reconstruct
it from the signature.

Simplifies the example testing a bit.

# User-Facing Changes
Causes a breaking change for plugins that previously declared it. While
this causes a compile fail, this was already broken by our more
stringent type checking.
This will be a good reminder for plugin authors to update their
signature as well to reflect the more stringent type checking.
2023-07-26 23:34:43 +02:00
Stefan Holderbach
d9230a76f3
Fix signatures for cellpath access of records (#9793)
# Description
The same procedure as for #9778 repeated for records.

# User-Facing Changes
Commands that directly supported applying their work directly to record
fields via cell paths, that worked before #9680 will now work again

# Tests + Formatting
Tried to limit the need to add new `.allow_variants_without_examples()`
by adjusting or adding tests to also use some records with access.
2023-07-26 23:13:57 +02:00
JT
f8d325dbfe
Set the rest variable to the correct type (#9816)
# Description

This fixes the type of `$rest` to be a `List<...>` so that it properly
is checked in function bodies.

fixes https://github.com/nushell/nushell/issues/9809
2023-07-26 20:22:08 +02:00
Darren Schroeder
88a890c11f
bump to dev version 0.83.1 (#9811)
# Description

This bumps nushell to the dev version of 0.83.1 and updates the default
config files with the proper version.

# User-Facing Changes
# Tests + Formatting
# After Submitting
2023-07-26 19:02:13 +02:00
Justin Ma
5a28371b18
Fix command docs deployment for input listen (#9805)
Fix command docs deployment for `input listen`, for more detail check:
https://github.com/nushell/nushell.github.io/pull/987
2023-07-26 07:00:23 -05:00
JT
a33b5fe6ce
bump to 0.83 (#9802)
# Description

Bump 0.83

# 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-26 07:36:36 +12:00
Stefan Holderbach
2080719162
Pin reedline to 0.22.0 release (#9794)
See release notes:

https://github.com/nushell/reedline/releases/tag/v0.22.0
2023-07-24 22:14:28 +02:00
Stefan Holderbach
9db0d6bd34
Adjust signatures for cellpath access of tables (#9778)
# Description
Reallow the commands that take cellpaths as rest parameters to operate
on table input data.

Went through all commands returned by

```
scope commands |
  filter { |cmd| $cmd.signatures |
    values |
    any {|sig| $sig |
      any {|$sig| $sig.parameter_type == rest and $sig.syntax_shape ==
cellpath }
    }
  } | get name
```

Only exception to that was `is-empty` that returns a bool.
# User-Facing Changes
Same table operations as in `0.82` should still be possible
Mitigates effects of #9680
2023-07-24 13:17:30 +02:00
Stefan Holderbach
d7ebe5fdc3
Update nu-ansi-term, lscolors, and reedline (#9787)
# Description
Now use `nu-ansi-term` 0.49
Small adjustments to accommodate breaking changes.


# User-Facing Changes
None
2023-07-24 13:16:18 +02:00
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