Commit Graph

7656 Commits

Author SHA1 Message Date
Michael Angerman
c59d9dc306
update rust-toolchain doc to 4 weeks from 3 (#10140)
When we updated our release schedule from 3 weeks to 4 weeks the doc on
the toolchain
file was never updated so I went ahead and did that...
2023-08-28 20:57:03 -07:00
Horasal
1f06f8405c
handle empty pipeline while parsing let (fix Issue10083) (#10116)
- fixes #10083 

# Description

nushell crashes in the following 2 condition:

- `let a = {}` , then delete `{`
- `let a = | {}`, then delete `{`

When delete `{` the pipeline becomes empty but current `nu-parser`
assume they are non-empty. This pr adds extra empty check to avoid
crash.


Co-authored-by: Horasal <horsal@horsal.dev>
2023-08-28 13:38:11 +02:00
Skyler Hawthorne
38f454d5ab
Support Termux (#10013) 2023-08-28 09:53:25 +03:00
SED4906
487f1a97ea
Update removed "MDI" icons to current MD icons (#10126)
# Description
This PR updates now-removed (since NF 3.0.0) file icons shown in e.g.
`grid` to their updated codepoints.

# User-Facing Changes
File icons changed were for:
`cs`, `csproj`, `csx`, `license`, `node`, `rtf`, `vue`, `xml`, and `xul`

# Tests + Formatting

# After Submitting
2023-08-27 15:48:37 +02:00
Darren Schroeder
0f05475e2e
name hooks internally (#10127)
# Description

This PR names the hooks as they're executing so that you can see them
with debug statements. So, at the beginning of `eval_hook()` you could
put a dbg! or eprintln! to see what hook was executing. It also shows up
in View files.

### Before - notice item 14 and 25

![image](https://github.com/nushell/nushell/assets/343840/22c19bbe-6bac-4132-9579-863922d91f22)

### After - The hooks are now named (14 & 25)

![image](https://github.com/nushell/nushell/assets/343840/a08abd11-4f03-4f09-bbac-e4b5180df078)


Curiosity, on my mac, the display_output hook fires 3 times before
anything else. Also, curious is that the value if the display_output, is
not what I have in my config but what is in the default_config. So,
there may be a bug or some shenanigans going on somewhere with hooks.

# 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-08-27 06:55:20 -05:00
Joaquín Triñanes
cc805f3f01
Screen reader-friendly errors (#10122)
- Hopefully closes #10120  

# Description

This PR adds a new config item, `error_style`. It will render errors in
a screen reader friendly mode when set to `"simple"`. This is done using
`miette`'s own `NarratableReportHandler`, which seamlessly replaces the
default one when needed.

Before:
```
Error: nu:🐚:external_command

  × External command failed
   ╭─[entry #2:1:1]
 1 │ doesnt exist
   · ───┬──
   ·    ╰── executable was not found
   ╰────
  help: No such file or directory (os error 2)
```

After:
```
Error: External command failed
    Diagnostic severity: error
Begin snippet for entry #4 starting at line 1, column 1

snippet line 1: doesnt exist
    label at line 1, columns 1 to 6: executable was not found
diagnostic help: No such file or directory (os error 2)
diagnostic code: nu:🐚:external_command

```

## Things to be determined

- ~Review naming. `errors.style` is not _that_ consistent with the rest
of the code. Menus use a `style` record, but table rendering mode is set
via `mode`.~ As it's a single config, we're using `error_style` for now.
- Should this kind of setting be toggable with one single parameter?
`accessibility.no_decorations` or similar, which would adjust the style
of both errors and tables accordingly.

# User-Facing Changes

No changes by default, errors will be rendered differently if
`error_style` is set to `simple`.

# 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

There's a PR updating the docs over here
https://github.com/nushell/nushell.github.io/pull/1026
2023-08-27 06:54:15 -05:00
Jakub Žádník
5ac5b90aed
Allow parse-time evaluation of calls, pipelines and subexpressions (#9499)
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
2023-08-26 16:41:29 +03:00
Antoine Stevan
3d73287ea4
add support for Vim motions in explore (#9966)
related to
- https://github.com/nushell/nushell/issues/7819

# Description
this PR does not quite address
https://github.com/nushell/nushell/issues/7819 because it does not
implement configurable keybindings for `explore` but rather only adds
support for Vim-like motions *out of the box*.

# User-Facing Changes
in *view* and *cursor* modes,
- `h`, `j`, `k` and `l` give standard Qwerty-based Vim motions
- `g` and `G` go to the top and the end respectively
- `u` and `d` scroll up and down

> **Note**
> the bindings do not support the use of modifiers for now, so it's not
`c-u` and `c-d` which scroll pages but rather `u` and `d`

# Tests + Formatting

# After Submitting
2023-08-26 07:48:37 -05:00
Hofer-Julian
7ebdced256
toolkit: Renames pretty-print-command (#10110)
It doesn't print, but returns a string.
So it should be called format.
2023-08-25 19:23:30 +02:00
nibon7
ad12018199
Use built-in is_terminal instead of is_terminal::is_terminal (#9550)
# Description
This PR tries to remove ~atty~ is-terminal from the entire code base,
since ~[atty is
unmaintained](https://rustsec.org/advisories/RUSTSEC-2021-0145) and~
[`is_terminal` has been
stabilized](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html#isterminal)
in rust 1.70.0.

cc @fdncred 

# 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.
-->
2023-08-25 10:54:44 +02:00
nibon7
27dcc3ecc3
Don't use oldtime feature of chrono (#9577)
<!--
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
`chrono` crate enables `oldtime` feature by default, which has a
vulnerability (https://rustsec.org/advisories/RUSTSEC-2020-0071). This
PR tries to remove `time` v0.1.45 completely from nu and add an audit CI
to check for security vulnerabilities.

 Wait for the following PRs:
- [x] https://github.com/nushell/reedline/pull/599
- [x] https://github.com/bspeice/dtparse/pull/44
- [x] https://github.com/Byron/trash-rs/pull/75
- [x] https://gitlab.com/imp/chrono-humanize-rs/-/merge_requests/15

# 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: sholderbach <sholderbach@users.noreply.github.com>
2023-08-25 10:54:01 +02:00
Horasal
e25a795cf6
Add encoding auto-detection for decode (#10030)
# Description
Allow `decode` command to guess the encoding of input if no encoding
name is given.

# User-Facing Changes

* `decode` now has an optional parameter instead of required one. User
can just run `decode` to let the command automatically detect encoding
and convert it to utf-8.
<img width="575" alt="Example"
src="https://github.com/nushell/nushell/assets/1991933/03a0ba11-910e-4db9-89aa-79cfec06893f">



* Based on the detect result, user may have to give a encoding name
<img width="572" alt="Error Sample1"
src="https://github.com/nushell/nushell/assets/1991933/f21fda85-1f04-4cb3-9feb-cb9fb7dcee07">
     or get informed that the input is not supported by `decode`
<img width="568" alt="Error Sample2"
src="https://github.com/nushell/nushell/assets/1991933/dd3cc4c0-f119-493e-8609-d07594fc055a">

# Tests + Formatting

* `cargo fmt --all -- --check` : OK
* `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err`: OK
* `cargo test --workspace` : OK
* `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"`: OK


# After Submitting

[Command document](https://www.nushell.sh/commands/docs/decode.html) is
auto-generated and requires no action.

---------

Co-authored-by: Horasal <horsal@horsal.dev>
2023-08-24 19:21:17 -05:00
Darren Schroeder
16c15e83a3
bump rust-toolchain to 1.70.0 (#10113)
# Description

This PR bumps the rust-toolchain to 1.70.0 since 1.72.0 was released
today.

# 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-08-24 19:13:57 -05:00
Matthias Q
cea67cb30b
Allow for .parq file ending as alternative to .parquet (#10112)
# Description

Many systems like Hadoops HDFS store parquet files with the short
variant `.parq`. It is quite annoying to rename these file before
opening them with nushell. This PR lets nushell accept .parq alongside
.parquet file endings.


# User-Facing Changes
Not sure if this is applicable here.

# Tests + Formatting

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 -  (fails on
none related test)
- `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library -
✔️
2023-08-24 15:57:33 -05:00
JT
1e3e034021
Spanned Value step 1: span all value cases (#10042)
# Description

This doesn't really do much that the user could see, but it helps get us
ready to do the steps of the refactor to split the span off of Value, so
that values can be spanless. This allows us to have top-level values
that can hold both a Value and a Span, without requiring that all values
have them.

We expect to see significant memory reduction by removing so many
unnecessary spans from values. For example, a table of 100,000 rows and
5 columns would have a savings of ~8megs in just spans that are almost
always duplicated.

# User-Facing Changes

Nothing yet

# 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-25 08:48:05 +12:00
Ian Manske
8da27a1a09
Create Record type (#10103)
# Description
This PR creates a new `Record` type to reduce duplicate code and
possibly bugs as well. (This is an edited version of #9648.)
- `Record` implements `FromIterator` and `IntoIterator` and so can be
iterated over or collected into. For example, this helps with
conversions to and from (hash)maps. (Also, no more
`cols.iter().zip(vals)`!)
- `Record` has a `push(col, val)` function to help insure that the
number of columns is equal to the number of values. I caught a few
potential bugs thanks to this (e.g. in the `ls` command).
- Finally, this PR also adds a `record!` macro that helps simplify
record creation. It is used like so:
   ```rust
   record! {
       "key1" => some_value,
       "key2" => Value::string("text", span),
       "key3" => Value::int(optional_int.unwrap_or(0), span),
       "key4" => Value::bool(config.setting, span),
   }
   ```
Since macros hinder formatting, etc., the right hand side values should
be relatively short and sweet like the examples above.

Where possible, prefer `record!` or `.collect()` on an iterator instead
of multiple `Record::push`s, since the first two automatically set the
record capacity and do less work overall.

# User-Facing Changes
Besides the changes in `nu-protocol` the only other breaking changes are
to `nu-table::{ExpandedTable::build_map, JustTable::kv_table}`.
2023-08-25 07:50:29 +12:00
Hofer-Julian
030e749fe7
Add notice to enable develop mode on Windows (#10111)
Developer mode needs to be enabled to create symlinks on Windows. Since
creating symlinks is part of the testbench, this needs to be enabled.

(I always wondered why two tests fail on my Windows machine, but not on
the CI)
2023-08-24 11:02:54 -07:00
Herobs
a785e64bc9
Fix 9156 endian consistency (#9873)
- fixed #9156

# Description
I'm trying to fix the problems mentioned in the issue. It's my first
attempt in Rust. Please let me know if there are any problems.

# User-Facing Changes
- The `--little-endian` option dropped, replaced with `--endian`.
- Add the `--compact` option to the `into binary` command.
- `into int` accepts binary input
2023-08-24 07:08:58 -05:00
goldfish
d4eeef4bd1
Fix tab completion order of directories to consistent with order of files (#10102)
# Description

fixed #10020

Tab completion order of directories is inconsistent with order of files.
This problem is caused by sorting folder names containing a trailing
slash.
This PR fixes the problem.

# User-Facing Changes

Users get the same order of suggestions in the tab completion for both
file and directory.


![image](https://github.com/nushell/nushell/assets/37319612/208e5a01-01a2-489c-b41a-36ece999f971)


# Tests + Formatting

```
$ toolkit check pr

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
```

# After Submitting

nothing
2023-08-24 06:19:13 -05:00
Reilly Wood
c8a07d477f
Fix watch not detecting modifications on Windows (#10109)
Closes #9910 FOR REAL this time.

I had fixed the issue on Linux but not Windows. Context:
https://github.com/nushell/nushell/issues/9910#issuecomment-1689308886

I've tested this PR successfully on Windows, Linux, and macOS by running
`watch . {|a,b| print $a; print $b}` and confirming that it prints once
when I change a file in the current directory.
2023-08-23 19:07:39 -07:00
Darren Schroeder
af82eeca72
remove --column from length command and remove record processing (#10091)
# Description

This PR removes `record` processing from the `length` command. It just
doesn't make sense to try and get the length of a record. This PR also
removes the `--column` parameter. If you want to list or count columns,
you could use `$table | columns` or `$table | columns | length`.

close #10074 

### Before

![image](https://github.com/nushell/nushell/assets/343840/83488316-3ec4-4c32-9583-00341a71f46f)

### After
Catches records two different ways now.
with the `input_output_types` checker

![image](https://github.com/nushell/nushell/assets/343840/ca67f8b6-359e-4933-ab4d-1b702f8d79cf)

and with additional logic in the command for cases like `echo`

![image](https://github.com/nushell/nushell/assets/343840/99064351-b208-4bd3-bab9-535f97cd7ad4)


# 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
- `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-23 16:03:26 -05:00
Darren Schroeder
3d698b74d8
bump nushell to dev version 0.84.1 (#10101)
# Description

This PR bumps nushell from release version 0.84.0 to dev version 0.84.1.

# 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
- `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-23 15:23:27 -05:00
Stefan Holderbach
d2abb8603a
Remove illegal star dependency (#10095)
The wildcard dev-dependency added in #9632 blocked us from publishing
the crate

Co-authored-by: JT <547158+jntrnr@users.noreply.github.com>
2023-08-23 09:09:23 +12:00
JT
894e0f7658
bump to 0.84 (#10093) 2023-08-22 21:23:39 +03:00
Antoine Stevan
a5087c4966
remove Clippy flags from the PR template (#10087)
related to
- https://github.com/nushell/nushell/pull/10072
- https://github.com/nushell/nushell/pull/10073

cc/ @sholderbach 

# Description
i think the PR template was the missing place where a `cargo clippy`
appears 😏
2023-08-21 19:45:48 +02:00
Darren Schroeder
ac4ab452d4
update install/build scripts to include --locked (#10086)
# Description

This PR updates the toolkit and the build/install scripts to include
`--locked`, also added `extra` feature to the _all_ scripts, and
`--force` to the install scripts.

# 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-21 12:42:42 -05:00
JT
5378727049
Revert "pin serde to avoid https://github.com/serde-rs/serde/issues/2538" (#10078)
Reverts nushell/nushell#10061

The latest serde (1.0.184) reverts the binary requirement.
2023-08-22 05:04:34 +12:00
Darren Schroeder
0786ddddbd
allow help to return a Type::Table (#10082)
# Description

This PR changes the signature of the `help` command so that it can
return a `Type::Table`.

closes #10077 

# 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-21 07:46:44 -05:00
Stefan Holderbach
7617084ca3
Polish CONTRIBUTING, add Rust style (#10071)
Add a table of contents and fix some imprecise information

Adds a proposed Rust style guide based on how things are reviewed at the
moment.
2023-08-21 17:17:18 +12:00
Stefan Holderbach
28941f1a06
Remove global clippy -A from toolkit.nu (#10073)
# Description
Same procedure as in #10072
2023-08-21 00:10:44 +02:00
Stefan Holderbach
43ceb3edec
Remove clippy global -A from CI (#10072)
# Description
We allowed two default lints due to false positives. This should be
locally addressed with explicit information what causes either a false
positive or why a particular design choice in the code is made.


# User-Facing Changes
None

# Tests + Formatting
We should detect a few more things with clippy out of the box. If you
encounter a false positive you will need to address it on a case by case
basis.
2023-08-21 00:08:49 +02:00
Stefan Holderbach
bffd8e4dd2
Pin reedline to 0.23.0 (#10070)
See release notes:

https://github.com/nushell/reedline/releases/tag/v0.23.0
2023-08-20 23:45:36 +02:00
Jakub Žádník
66023f6243
Remove "let config" warning (#10068)
If you have a `config` variable defined at some point after reading
config files, Nushell would print
```
warning: use `$env.config = ...` instead of `let config = ...`
```

I think it's long enough since we've used `$env.config` that we can
remove this. Furthermore, it should be printed during `let` parsing
because you can end up with a `config` constant after importing a
`config` module (that was my case). The warning thus can be misleading.
2023-08-20 22:02:52 +02:00
Jakub Žádník
10fc32e3ef
Simplify virtualenv testing (#10035)
Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
2023-08-20 17:00:59 +03:00
Jakub Žádník
3148acd3a4
Recursively export constants from modules (#10049)
<!--
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.
-->

https://github.com/nushell/nushell/pull/9773 introduced constants to
modules and allowed to export them, but only within one level. This PR:
* allows recursive exporting of constants from all submodules
* fixes submodule imports in a list import pattern
* makes sure exported constants are actual constants

Should unblock https://github.com/nushell/nushell/pull/9678

### Example:
```nushell
module spam {
    export module eggs {
        export module bacon {
            export const viking = 'eats'
        }
    }
}

use spam 
print $spam.eggs.bacon.viking  # prints 'eats'

use spam [eggs]
print $eggs.bacon.viking  # prints 'eats'

use spam eggs bacon viking
print $viking  # prints 'eats'
```

### Limitation 1:

Considering the above `spam` module, attempting to get `eggs bacon` from
`spam` module doesn't work directly:
```nushell
use spam [ eggs bacon ]  # attempts to load `eggs`, then `bacon`
use spam [ "eggs bacon" ]  # obviously wrong name for a constant, but doesn't work also for commands
```

Workaround (for example):
```nushell
use spam eggs
use eggs [ bacon ]

print $bacon.viking  # prints 'eats'
```

I'm thinking I'll just leave it in, as you can easily work around this.
It is also a limitation of the import pattern in general, not just
constants.

### Limitation 2:

`overlay use` successfully imports the constants, but `overlay hide`
does not hide them, even though it seems to hide normal variables
successfully. This needs more investigation.

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

Allows recursive constant exports from submodules.

# 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-20 14:51:35 +02:00
Darren Schroeder
e6ce8a89be
try and fix into datetime to accept more dt formats (#10063)
# Description

This PR tries to fix `into datetime`. The problem was that it didn't
support many input formats and the `--format` was clunky. `--format` is
still a bit clunky but can work. The big change here is that it first
tries to use `dtparse` to convert text into datetime.

### Before
```nushell
❯ '20220604' | into datetime
Thu, 01 Jan 1970 00:00:00 +0000 (53 years ago)
```
### After
```nushell
❯ '20220604' | into datetime
Sat, 04 Jun 2022 00:00:00 -0500 (a year ago)
```
## Supported Input Formats
`dtparse` should support all these formats. Taken from their
[repo](https://github.com/bspeice/dtparse/blob/master/build_pycompat.py).
```python
    'test_parse_default': [
        "Thu Sep 25 10:36:28",
        "Sep 10:36:28", "10:36:28", "10:36", "Sep 2003", "Sep", "2003",
        "10h36m28.5s", "10h36m28s", "10h36m", "10h", "10 h 36", "10 h 36.5",
        "36 m 5", "36 m 5 s", "36 m 05", "36 m 05 s", "10h am", "10h pm",
        "10am", "10pm", "10:00 am", "10:00 pm", "10:00am", "10:00pm",
        "10:00a.m", "10:00p.m", "10:00a.m.", "10:00p.m.",
        "October", "31-Dec-00", "0:01:02", "12h 01m02s am", "12:08 PM",
        "01h02m03", "01h02", "01h02s", "01m02", "01m02h", "2004 10 Apr 11h30m",
        # testPertain
        'Sep 03', 'Sep of 03',
        # test_hmBY - Note: This appears to be Python 3 only, no idea why
        '02:17NOV2017',
        # Weekdays
        "Thu Sep 10:36:28", "Thu 10:36:28", "Wed", "Wednesday"
    ],
    'test_parse_simple': [
        "Thu Sep 25 10:36:28 2003", "Thu Sep 25 2003", "2003-09-25T10:49:41",
        "2003-09-25T10:49", "2003-09-25T10", "2003-09-25", "20030925T104941",
        "20030925T1049", "20030925T10", "20030925", "2003-09-25 10:49:41,502",
        "199709020908", "19970902090807", "2003-09-25", "09-25-2003",
        "25-09-2003", "10-09-2003", "10-09-03", "2003.09.25", "09.25.2003",
        "25.09.2003", "10.09.2003", "10.09.03", "2003/09/25", "09/25/2003",
        "25/09/2003", "10/09/2003", "10/09/03", "2003 09 25", "09 25 2003",
        "25 09 2003", "10 09 2003", "10 09 03", "25 09 03", "03 25 Sep",
        "25 03 Sep", "  July   4 ,  1976   12:01:02   am  ",
        "Wed, July 10, '96", "1996.July.10 AD 12:08 PM", "July 4, 1976",
        "7 4 1976", "4 jul 1976", "7-4-76", "19760704",
        "0:01:02 on July 4, 1976", "0:01:02 on July 4, 1976",
        "July 4, 1976 12:01:02 am", "Mon Jan  2 04:24:27 1995",
        "04.04.95 00:22", "Jan 1 1999 11:23:34.578", "950404 122212",
        "3rd of May 2001", "5th of March 2001", "1st of May 2003",
        '0099-01-01T00:00:00', '0031-01-01T00:00:00',
        "20080227T21:26:01.123456789", '13NOV2017', '0003-03-04',
        'December.0031.30',
        # testNoYearFirstNoDayFirst
        '090107',
        # test_mstridx
        '2015-15-May',
    ],
    'test_parse_tzinfo': [
        'Thu Sep 25 10:36:28 BRST 2003', '2003 10:36:28 BRST 25 Sep Thu',
    ],
    'test_parse_offset': [
        'Thu, 25 Sep 2003 10:49:41 -0300', '2003-09-25T10:49:41.5-03:00',
        '2003-09-25T10:49:41-03:00', '20030925T104941.5-0300',
        '20030925T104941-0300',
        # dtparse-specific
        "2018-08-10 10:00:00 UTC+3", "2018-08-10 03:36:47 PM GMT-4", "2018-08-10 04:15:00 AM Z-02:00"
    ],
    'test_parse_dayfirst': [
        '10-09-2003', '10.09.2003', '10/09/2003', '10 09 2003',
        # testDayFirst
        '090107',
        # testUnambiguousDayFirst
        '2015 09 25'
    ],
    'test_parse_yearfirst': [
        '10-09-03', '10.09.03', '10/09/03', '10 09 03',
        # testYearFirst
        '090107',
        # testUnambiguousYearFirst
        '2015 09 25'
    ],
    'test_parse_dfyf': [
        # testDayFirstYearFirst
        '090107',
        # testUnambiguousDayFirstYearFirst
        '2015 09 25'
    ],
    'test_unspecified_fallback': [
        'April 2009', 'Feb 2007', 'Feb 2008'
    ],
    'test_parse_ignoretz': [
        'Thu Sep 25 10:36:28 BRST 2003', '1996.07.10 AD at 15:08:56 PDT',
        'Tuesday, April 12, 1952 AD 3:30:42pm PST',
        'November 5, 1994, 8:15:30 am EST', '1994-11-05T08:15:30-05:00',
        '1994-11-05T08:15:30Z', '1976-07-04T00:01:02Z', '1986-07-05T08:15:30z',
        'Tue Apr 4 00:22:12 PDT 1995'
    ],
    'test_fuzzy_tzinfo': [
        'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.'
    ],
    'test_fuzzy_tokens_tzinfo': [
        'Today is 25 of September of 2003, exactly at 10:49:41 with timezone -03:00.'
    ],
    'test_fuzzy_simple': [
        'I have a meeting on March 1, 1974', # testFuzzyAMPMProblem
        'On June 8th, 2020, I am going to be the first man on Mars', # testFuzzyAMPMProblem
        'Meet me at the AM/PM on Sunset at 3:00 AM on December 3rd, 2003', # testFuzzyAMPMProblem
        'Meet me at 3:00 AM on December 3rd, 2003 at the AM/PM on Sunset', # testFuzzyAMPMProblem
        'Jan 29, 1945 14:45 AM I going to see you there?', # testFuzzyIgnoreAMPM
        '2017-07-17 06:15:', # test_idx_check
    ],
```
# 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-20 07:32:48 -05:00
Darren Schroeder
74f8081290
allow return to return any nushell value (#10067)
# Description

This PR allows the `return` command to return any nushell value.

### Before

![image](https://github.com/nushell/nushell/assets/343840/2c0a70d7-86e4-4c7f-bd3a-d7c7d74b1c1a)

### After

![image](https://github.com/nushell/nushell/assets/343840/f428d486-4a4f-4058-a29f-7d7a845e08f7)


# 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-20 07:30:54 -05:00
JT
2ae1de2470
move 'bytes' back to commands (#10051)
# Description

Moves the `bytes XXXX` commands back to the default set.
2023-08-19 22:43:53 +02:00
Antoine Stevan
028a327ce8
Revert "deprecate --format and --list in into datetime (#10017)" (#10055)
related to 
-
https://github.com/nushell/nushell/issues/10017#issuecomment-1683082039

# Description
this PR undeprecates `into datetime --format` and `into datetime
--list`.

this PR reverts commit f33b60c001.

# User-Facing Changes

# Tests + Formatting

# After Submitting
2023-08-19 14:34:16 -05:00
JT
318862aad6
pin serde to avoid https://github.com/serde-rs/serde/issues/2538 (#10061)
Context: https://github.com/serde-rs/serde/issues/2538

As other projects are investigating, this should pin serde to the last
stable release before binary requirements were introduced.

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

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

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -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-20 05:50:26 +12:00
Antoine Stevan
9f4510f2e1
make the charpage optional for std clip (#10053)
related to
-
https://discord.com/channels/601130461678272522/615253963645911060/1142060647358668841

# Description
in order to make the charpage for Windows as general as possible, `chcp`
will only run on Windows when `--charpage` is given an integer.

while i was at it, i fixed the system messages given to
`check-clipboard` because some of the were incorrect => see the second
commit 6865ec9a5

# User-Facing Changes
this is a breaking change as users relying on the fact that `std clip`
changed the page to `65001` by itself is not true anymore => they will
have to add `--charpage 65001`.

# Tests + Formatting

# After Submitting
2023-08-19 10:18:50 -05:00
Darren Schroeder
98c7ab96b6
enable/update some example tests so they work again (#10058)
# Description

This PR updates some `Example` tests so that they work again. The only
one I couldn't figure out is the one in the `filter` command. It should
work but does not. However, I left the test in because it's valuable, it
just has a `None` result. I'd like to fix this but I'm not sure how.

# 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-19 09:06:59 -05:00
Darren Schroeder
13114e972b
try to document the more obscure testbin commands (#10057)
# Description

This PR tries to document some of the more obscure testbin parameters
and what they do. I still don't grok all of them.

# 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-19 08:23:11 -05:00
JT
4a1b3e26ef
fix default-env after latest changes (#10052)
# Description

default env.nu is currently broken after the changes to `str replace`.
This PR should help fix it.

# 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-19 07:39:36 +12:00
Maxim Zhiburt
1e3248dfe8
nu-table: fix issue with truncation and text border (#10050)
I did only few manual tests, so maybe shall be run before.

todo: maybe need to add a test case for it.

fix #9993
cc: @fdncred

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
2023-08-18 13:28:33 -05:00
Jakub Žádník
2aa4cd5cc5
Add a few more fields to scope commands (#10045) 2023-08-18 20:47:38 +03:00
Jakub Žádník
fb908df17d
Add additional span to IncorrectValue error (#10036) 2023-08-18 20:47:05 +03:00
Jakub Žádník
cdf09abcc0
Allow exporting extern-wrapped (#10025) 2023-08-18 20:45:33 +03:00
Jakub Žádník
fe2c498a81
Fix wrong path expansion in save (#10046) 2023-08-18 20:45:10 +03:00
Darren Schroeder
fe7122280d
allow int as a cellpath for select (#10048)
Description

This PR allows ints to be used as cell paths.

### Before
```nushell
❯ let index = 0
❯ locations | select $index
Error: nu:🐚:cant_convert

  × Can't convert to cell path.
   ╭─[entry #26:1:1]
 1 │ locations | select $index
   ·                    ───┬──
   ·                       ╰── can't convert int to cell path
   ╰────
```

### After
```nushell
❯ let index = 0
❯ locations | select $index
╭#┬───────location────────┬city_column┬state_column┬country_column┬lat_column┬lon_column╮
│0│http://ip-api.com/json/│city       │region      │countryCode   │lat       │lon       │
╰─┴───────────────────────┴───────────┴────────────┴──────────────┴──────────┴──────────╯
```
# 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-18 10:16:18 -05:00