Commit Graph

1365 Commits

Author SHA1 Message Date
Stefan Holderbach
bd0032898f
Apply nightly clippy lints (#9654)
# Description
- A new one is the removal of unnecessary `#` in raw strings without `"`
inside.
-
https://rust-lang.github.io/rust-clippy/master/index.html#/needless_raw_string_hashes
- The automatically applied removal of `.into_iter()` touched several
places where #9648 will change to the use of the record API. If
necessary I can remove them @IanManske to avoid churn with this PR.
- Manually applied `.try_fold` in two places
- Removed a dead `if`
- Manual: Combat rightward-drift with early return
2023-07-12 00:00:31 +02:00
Yassine Haouzane
628a47e6dc
Fix: update engine_state when history.isolation is true (#9268) (#9616)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

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

# Description
Fixes #9268, the issue was due to the fact that when `history_isolation`
was set to true the engine_state's `session_id` wasn't updated.

This PR mainly refactors the code that updates the line_editor's history
information into one function `update_line_editor_history` and also
updates the engine_state's `session_id` when `history_isolation` is set
to `true` by calling the function `store_history_id_in_engine`.
<!--
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. -->
None since it's a bug fix.

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

I tried to extract the block that was updating the line_editor's
`session_id` to make it easier to add a test.
The test checks that after a call to the function
`update_line_editor_history`, the `engine_state` and the returned
`line_editor` do have the same `session_id`.
2023-07-06 20:16:17 -05:00
Stefan Holderbach
881c3495c1
Exclude deprecated commands from completions (#9612)
# Description
We previously simply searched all commands in the working set. As our
deprecated/removed subcommands are documented by stub commands that
don't do anything apart from providing a message, they were still
included.
With this change we check the `Signature.category` to not be
`Category::Deprecated`.

## Note on performance
Making this change will exercise `Command.signature()` more
frequently! As the rust-implemented commands include their builders here
this probably will cause a number of extra allocations. There is
actually no valid reason why the commands should construct a new
`Signature` for each call to `Command.signature()`.
This will introduce some overhead to generate the completions for
commands.
# User-Facing Changes
Example: `str <TAB>`


![grafik](https://github.com/nushell/nushell/assets/15833959/4d5ec5fe-aa93-45af-aa60-3854a20fcb04)
2023-07-05 23:13:16 +02:00
JT
5d9e2455f7
Let with pipeline (#9589)
# Description

This changes the default behaviour of `let` to be able to take a
pipeline as its initial value.

For example:

```
> let x = "hello world" | str length
```

This is a change from the existing behaviour, where the right hand side
is assumed to be an expression. Pipelines are more general, and can be
more powerful.

My google foo is failing me, but this also fixes this issue:

```
let x = foo
```

Currently, this reads `foo` as a bareword that gets converted to a
string rather than running the `foo` command. In practice, this is
really annoying and is a really hard to spot bug in a script.

# User-Facing Changes

BREAKING CHANGE BREAKING CHANGE

`let` gains the power to be assigned via a pipeline. However, this
changes the behaviour of `let x = foo` from assigning the string "foo"
to `$x` to being "run the command `foo` and give the result to `$x`"

# 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-07-03 17:45:10 +12:00
WindSoilder
4acf21cdcf
Bracketed paste refactor (#9547)
<!--
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
This pr is a completion of https://github.com/nushell/reedline/pull/598

After that pr is merged, we no longer need to disable bracketed mode in
nushell

# 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-07-02 14:11:12 -05:00
Stefan Holderbach
088e6dffbe
Bump to 0.82.1 dev version (#9543)
# Description
Marks development or hotfix
2023-06-27 21:33:53 +02:00
Stefan Holderbach
ecdb023e2f
Bump version for 0.82.0 release (#9530)
# Checklist

- `nu-ansi-term` remains the same
- [x] `reedline` is released and updated
- [x] release scripts are updated for `nu-cmd-base`
- [x] info blog post is online
- [ ] release notes are ready
2023-06-27 19:11:46 +02:00
Stefan Holderbach
63aba5feb7
Pin reedline to 0.21 for release (#9532)
# Description
See changelog:
https://github.com/nushell/reedline/releases/tag/v0.21.0
2023-06-26 12:47:59 +02:00
Michael Angerman
d1449c4ee7
cratification: move the bytes command to nu-cmd-extra (#9509)
now that #9455 has landed we can move the bytes command to nu-cmd-extra

in concert with

moving nu_command::util to nu-cmd-base
2023-06-23 12:23:08 -07:00
JT
fbf3f7cf1c
split $nu variable into scope commands and simpler $nu (#9487)
# Description

This splits off `scope` from `$nu`, creating a set of `scope` commands
for the various types of scope you might be interested in.

This also simplifies the `$nu` variable a bit.

# User-Facing Changes

This changes `$nu` to be a bit simpler and introduces a set of `scope`
subcommands.

# 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-06-21 09:33:01 +12:00
dependabot[bot]
d2629293e8
Bump once_cell from 1.17.1 to 1.18.0 (#9474) 2023-06-19 06:16:00 +00:00
JT
6c730def4b
revert: move to ahash (#9464)
This PR reverts https://github.com/nushell/nushell/pull/9391

We try not to revert PRs like this, though after discussion with the
Nushell team, we decided to revert this one.

The main reason is that Nushell, as a codebase, isn't ready for these
kinds of optimisations. It's in the part of the development cycle where
our main focus should be on improving the algorithms inside of Nushell
itself. Once we have matured our algorithms, then we can look for
opportunities to switch out technologies we're using for alternate
forms.

Much of Nushell still has lots of opportunities for tuning the codebase,
paying down technical debt, and making the codebase generally cleaner
and more robust. This should be the focus. Performance improvements
should flow out of that work.

Said another, optimisation that isn't part of tuning the codebase is
premature at this stage. We need to focus on doing the hard work of
making the engine, parser, etc better.

# User-Facing Changes

Reverts the HashMap -> ahash change.

cc @FilipAndersson245
2023-06-18 15:27:57 +12:00
Stefan Holderbach
46eebc644c
Break up interdependencies of command crates (#9429)
# Description
Make sure that our different crates that contain commands can be
compiled in parallel.
This can under certain circumstances accelerate the compilation with
sufficient multithreading available.

## Details
- Move `help` commands from `nu-cmd-lang` back to `nu-command`
- This also makes sense as the commands are implemented in an
ANSI-terminal specific way
- Make `nu-cmd-lang` only a dev dependency for `nu-command`
- Change context creation helpers for `nu-cmd-extra` and
`nu-cmd-dataframe` to have a consistent api used in
`src/main.rs`:`get_engine_state()`
- `nu-command` now indepedent from `nu-cmd-extra` and `nu-cmd-dataframe`
that are now dependencies of `nu` directly. (change to internal
features)
- Fix tests that previously used `nu-command::create_default_context()`
with replacement functions

## From scratch compilation times:

just debug (dev) build and default features
```
cargo clean --profile dev && cargo build --timings
```

### before

![grafik](https://github.com/nushell/nushell/assets/15833959/e49f1f42-2e53-4a6c-bc23-625b686af1bc)

### after

![grafik](https://github.com/nushell/nushell/assets/15833959/8dec4723-e625-4a86-b91e-e6e808f64726)

# User-Facing Changes
None direct, only change to compilation on multithreaded jobs expected.

# Tests + Formatting
Tests that previously chose to use `nu-command` for their scope will
still use `nu-cmd-lang` + `nu-command` (command list in the granularity
at the time)
2023-06-14 23:12:55 +02:00
Steven Xu
be53ecbbaa
refactor: merge repl_buffer_state, repl_cursor_pos into one mutex (#9031)
# Description
Merge `repl_buffer_state`, `repl_cursor_pos` into one mutex.

# User-Facing Changes

# Tests + Formatting

# After Submitting
2023-06-10 17:38:11 -05:00
Stefan Holderbach
374df9d69f
Enable history entry exclusion with leading space (#9371)
# Description
Makes use of the feature introduced by nushell/reedline#566

If we consider this to be problematic we can decide to add a config
point for this behavior, but at first I was a bit hesistant expanding
the config in this area.


# User-Facing Changes
Follows precedent found in bash/zsh/fish to exclude lines starting with
a space from the history.
Like in fish you can still recall the last entry once but it will not be
stored and will be forgotten after the next submitted entry.


# Tests + Formatting
(-)
2023-06-10 17:15:46 -05:00
Filip Andersson
1433f4a520
Changes HashMap to use aHash instead, giving a performance boost. (#9391)
# Description

see https://github.com/nushell/nushell/issues/9390
using `ahash` instead of the default hasher. this will not affect
compile time as we where already building `ahash`.


# 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-06-10 11:41:58 -05:00
WindSoilder
6e638ab381
disable bracketed paste during evaluation (#9399)
# Description
Fixes: #9218

When user execute some commands involve user input, currently if we
enable `bracketed_paste`, it will results strange behavior (Pasting `0~`
and `1~` around texts, e.g: `aaa` -> `0~aaa1~`) And this is why `gpg`
with paste failed.

Sorry that it's hard to make relative testing...

# 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-06-10 09:42:13 -05:00
Stefan Holderbach
d15859dd86
Bump to 0.81.1 as development version (#9379)
# Description
Primarily used as a marker on issues and if necessary as a patch release
version.
2023-06-07 15:06:42 +02:00
JT
63cb01e83b
bump to 0.81 (#9374)
# 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 -- 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-06-07 10:08:11 +12:00
Stefan Holderbach
ef38805ef9
Pin reedline to 0.20.0 release (#9370)
# Description
See release notes

https://github.com/nushell/reedline/releases/tag/v0.20.0
2023-06-06 13:16:18 +02:00
Jakub Žádník
82e6873702
Fix config creation during printing (#9353) 2023-06-04 22:04:28 +03:00
nibon7
560c2e63ac
restore cursor shape when exits (#9314)
# Description
This PR restores cursor shape when nushell exists.

Fixes #9243 

Related
[nushell/reedline#574](https://github.com/nushell/reedline/pull/574)

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

* windows


https://github.com/nushell/nushell/assets/15247421/ede8d1c0-ecd1-40b0-87b0-6393c1a7160f


* linux


https://github.com/nushell/nushell/assets/15247421/b428f17e-05cb-45ad-aa5f-3a9753fd9176

* macos


https://github.com/nushell/nushell/assets/15247421/5170dabd-8b9f-4bad-a7a2-bdabfca45cca

# 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-05-30 09:38:45 -05:00
Maxim Zhiburt
7f758d3e51
Merge stack before printing (#9304)
Could you @fdncred try it?

close?: #9264

---------

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-29 19:03:00 -05:00
Darren Schroeder
5f92fd20e9
update most dependencies except where deeper code changes are needed (#9296)
# Description

This PR updates most dependencies and tries to get in sync with
reedline.

# 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-05-26 10:32:48 -05:00
JT
43108de547
move over to reedline git version (#9283)
# Description
Moves us over to dogfooding the git version of reedline ahead of the
next release.

# User-Facing Changes

With luck, you should see fewer bugs :D

# 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-05-25 11:53:57 +12:00
Darren Schroeder
e752d8a964
remove unused dependencies (#9230)
# Description

This is a test PR to see if we can remove dependencies. The crates to
remove was generated from cargo machete. If ci works, I'll update the PR
to remove deps instead of comment them out.

# 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-05-18 11:37:20 -05:00
WindSoilder
b150f9f5d8
Avoid blocking when o+e> redirects too much stderr message (#8784)
# Description

Fixes: #8565

Here is another pr #7240 tried to address the issue, but it works in a
wrong way.

After this change `o+e>` won't redirect all stdout message then stderr
message and it works more like how bash does.

# User-Facing Changes

For the given python code:
```python
# test.py
import sys

print('aa'*300, flush=True)
print('bb'*999999, file=sys.stderr, flush=True)
print('cc'*300, flush=True)
```

Running `python test.py out+err> a.txt` shoudn't hang nushell, and
`a.txt` keeps output in the same order

## About the change
The core idea is that when doing lite-parsing, introduce a new variant
`LiteElement::SameTargetRedirection` if we meet `out+err>` redirection
token(which is generated by lex function),

During converting from lite block to block,
LiteElement::SameTargetRedirection will be converted to
PipelineElement::SameTargetRedirection.

Then in the block eval process, if we get
PipelineElement::SameTargetRedirection, we'll invoke `run-external` with
`--redirect-combine` flag, then pipe the result into save command

## What happened internally?

Take the following command as example:
`^ls o+e> log.txt`

lex parsing result(`Tokens`) are not changed, but `LiteBlock` and
`Block` is changed after this pr.
### LiteBlock before
```rust
LiteBlock {
    block: [
        LitePipeline { commands: [
            Command(None, LiteCommand { comments: [], parts: [Span { start: 39041, end: 39044 }] }),
            // actually the span of first Redirection is wrong too..
            Redirection(Span { start: 39058, end: 39062 }, StdoutAndStderr, LiteCommand { comments: [], parts: [Span { start: 39050, end: 39057 }] }),
        ]
    }]
}
```
### LiteBlock after
```rust
LiteBlock { 
    block: [
        LitePipeline {
            commands: [
                SameTargetRedirection {
                    cmd: (None, LiteCommand { comments: [], parts: [Span { start: 147945, end: 147948}]}),
                    redirection: (Span { start: 147949, end: 147957 }, LiteCommand { comments: [], parts: [Span { start: 147958, end: 147965 }]})
                }
            ]
        }
    ]
}
```
### Block before
```rust
Pipeline {
    elements: [
        Expression(None, Expression {
            expr: ExternalCall(Expression { expr: String("ls"), span: Span { start: 39042, end: 39044 }, ty: String, custom_completion: None }, [], false),
            span: Span { start: 39041, end: 39044 },
            ty: Any, custom_completion: None 
        }),
        Redirection(Span { start: 39058, end: 39062 }, StdoutAndStderr, Expression { expr: String("out.txt"), span: Span { start: 39050, end: 39057 }, ty: String, custom_completion: None })] }
```
### Block after
```rust
Pipeline {
    elements: [
        SameTargetRedirection { 
            cmd: (None, Expression {
                expr: ExternalCall(Expression { expr: String("ls"), span: Span { start: 147946, end: 147948 }, ty: String, custom_completion: None}, [], false),
                span: Span { start: 147945, end: 147948},
                ty: Any, custom_completion: None
            }),
            redirection: (Span { start: 147949, end: 147957}, Expression {expr: String("log.txt"), span: Span { start: 147958, end: 147965 },ty: String,custom_completion: None}
        }
    ]
}
```

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.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-05-17 17:47:03 -05:00
Darren Schroeder
057de06613
bump nushell from release version to development version (#9215)
# Description

Bump nushell to 0.80.1 development version

# 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-05-17 07:59:01 -05:00
Stefan Holderbach
8695b57584
Bump version for 0.80.0 release (#9212)
# Checklist

- [x] merged reedline PR
- [ ] release notes
2023-05-17 10:11:13 +12:00
Stefan Holderbach
c9652bce00
Pin reedline to 0.19.1 for 0.80 release (#9211)
# Description
This just includes the bracketed paste bugfix in nushell/reedline#577


# User-Facing Changes
None

# Tests + Formatting

# After Submitting
2023-05-17 10:05:24 +12:00
Bob Hyman
9e9fe83bfd
Parameter defaults to $nu.scope.commands (#9152)
(*third* try at posting this PR, #9104, like #9084, got polluted with
unrelated commits. I'm never going to pull from the github feature
branch again!)

# 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.
-->
Show parameter defaults in scope command signature, where they're
available for display by help.
per https://github.com/nushell/nushell/issues/8928.

I found unexpected ramifications in one completer (NuHelpCompleter) and
plugins, which both use the flag-formatting routine from builtin help.
For the moment I made the minimum necessary changes to get the mainline
scenario to pass tests and run. But we should circle back on what to do
with plugins and help completer..

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
1. New `parameter_default` column to `signatures` table in
`$nu.scope.commands`
It is populated with whatever parameters can be defaulted: currently
positional args and named flags.
2. Built in help (both `help <command>` and `<command> --help` will
display the defaults
3. Help completer will display defaults for flags, but not for
positionals.

Example:
A custom command with some default parameters:
```
〉cat ~/work/dflts.nu 
# sample function to show defaults in help
export def main [
    arg1: string        # mandatory positional
    arg2:string=abc     # optional positional
    --switch            # no default here
    --named:int         # named flag, no default
    --other:string=def  # flag 
    --hard:record<foo:int bar:string, bas:bool> # default can be compound type
            = {foo:22, bar:"other worlds", bas:false}
] { {arg1: $arg1,
    arg2: $arg2,
    switch: $switch,
    named: $named,
    other: $other,
    hard: $hard, }
}

〉use ~/work/dflts.nu

〉$nu.scope.commands | where name == 'dflts' | get signatures.0.any | reject short_flag description custom_completion
╭───┬────────────────┬────────────────┬──────────────────────────────────────────┬─────────────┬───────────────────────────╮
│ # │ parameter_name │ parameter_type │               syntax_shape               │ is_optional │     parameter_default     │
├───┼────────────────┼────────────────┼──────────────────────────────────────────┼─────────────┼───────────────────────────┤
│ 0 │                │ input          │ any                                      │ false       │                           │
│ 1 │ arg1           │ positional     │ string                                   │ false       │                           │
│ 2 │ arg2           │ positional     │ string                                   │ true        │ abc                       │
│ 3 │ switch         │ switch         │                                          │ true        │                           │
│ 4 │ named          │ named          │ int                                      │ true        │                           │
│ 5 │ other          │ named          │ string                                   │ true        │ def                       │
│ 6 │ hard           │ named          │ record<foo: int, bar: string, bas: bool> │ true        │ ╭───────┬───────────────╮ │
│   │                │                │                                          │             │ │ foo   │ 22            │ │
│   │                │                │                                          │             │ │ bar   │ other worlds  │ │
│   │                │                │                                          │             │ │ bas   │ false         │ │
│   │                │                │                                          │             │ ╰───────┴───────────────╯ │
│ 7 │                │ output         │ any                                      │ false       │                           │
╰───┴────────────────┴────────────────┴──────────────────────────────────────────┴─────────────┴───────────────────────────╯

〉help dflts
sample function to show defaults in help

Usage:
  > dflts {flags} <arg1> (arg2) 

Flags:
  --switch - switch -- no default here
  --named <Int> - named flag, typed, but no default
  --other <String> - flag with default (default: 'def')
  --hard <Record([("foo", Int), ("bar", String), ("bas", Boolean)])> - default can be compound type (default: {foo: 22, bar: 'other worlds', bas: false})
  -h, --help - Display the help message for this command

Parameters:
  arg1 <string>: mandatory positional
  arg2 <string>: optional positional (optional, default: 'abc')
```

Compared to (relevant bits of) help output previously:
```
Flags:
  -h, --help - Display the help message for this command
  -, --switch - no default here
  -, --named <int> - named flag, no default
  -, --other <string> - flag
  -, --hard <record<foo: int, bar: string, bas: bool>> - default can be compound type

Signatures:
  <any> | dflts <string> <string> -> <any>

Parameters:
  arg1 <string>: mandatory positional
  (optional) arg2 <string>: optional positional
```

# 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
> [x] 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-05-11 13:59:56 -05:00
Antoine Stevan
43a3983d36
REFACTOR: move the banner from the rust source to the standard library (#8406)
Related to:
- #8311 
- #8353

# Description
with the new `$nu.startup-time` from #8353 and as mentionned in #8311,
we are now able to fully move the `nushell` banner from the `rust`
source base to the standard library.

this PR
- removes all the `rust` source code for the banner
- rewrites a perfect clone of the banner to `std.nu`, called `std
banner`
- call `std banner` from `default_config.nu`

# User-Facing Changes
see the demo: https://asciinema.org/a/566521

- no config will show the banner (e.g. `cargo run --release --
--no-config-file`)
- a custom config without the `if $env.config.show_banner` block and no
call to `std banner` would never show the banner
- a custom config with the block and `config.show_banner = true` will
show the banner
- a custom config with the block and `config.show_banner = false` will
NOT show the banner

# Tests + Formatting
a new test line has been added to `tests.nu` to check the length of the
`std banner` output.
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
```
$nothing
```

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-05-10 07:05:01 -05:00
Steven Xu
2a484a3e7e
fix: use buffer.len() instead of cursor_pos, so the .expect() isn't useless (#9053)
# Description
Use `buffer.len()` instead of `cursor_pos`, so the `.expect()` isn't
useless.

# User-Facing Changes

# Tests + Formatting

# After Submitting
2023-05-08 13:02:01 -05:00
Antoine Stevan
a78cd6e231
FIX: add a space after the default left prompt (#9074)
# Description
when running `nushell` with the `--no-config-file` option, the left
prompt does not have a space to separate the directory path from the
user input.
in this PR i add a space there to make the prompt easier to read when
using `--no-config-file`!

# User-Facing Changes
before: https://asciinema.org/a/581733
after: https://asciinema.org/a/581734

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

# After Submitting
```
$nothing
```
2023-05-08 13:00:44 -05:00
WindSoilder
e4625acf24
support bracketed paste (#8907)
# Description

Relative: #8113, #7630
It works on non-windows system

This pr depends on https://github.com/nushell/reedline/pull/571
2023-05-03 23:08:47 +02:00
Darren Schroeder
e590d3587c
enable history isolation (#9063)
# Description
This PR impacts the nushell sqlite history only.

This is the first PR that enables history isolation in nushell for the
sqlite history. Hopefully, we can continue building on this.

This PR allows "history isolation" which means that other nushell
session's history won't be available in the current session when using
the uparrow/downarrow history navigation. This change only impacts the
uparrow downarrow history navigation.

What remains to be done is making ctrl+r history menu respect this
setting too. Right now, the history menu will still show you all entries
from all sessions.

The history command also shows all history items from all sessions. This
may remain unchanged since you can just filter by history session right
now.

This also fixes a bug where the session id is 0 in the sqlite history
since my April 18th reedline PR.

Closes #9064

# 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-05-01 08:11:38 -05:00
Steven Xu
b37662c7e1
fix: fix cursor position when cursor is at the end of the commandline (#9030)
# Description
Fix getting the cursor position, when it's at the end of the
commandline.

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

# Tests + Formatting

# After Submitting
2023-04-28 07:02:45 -05:00
Darren Schroeder
6047b04208
fix compilation error (#9016)
# Description
This PR fixes a problem due to me landing an out of date PR that stopped
nushell from compiling.

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `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-04-26 14:38:09 -05:00
goldfish
c422c6cc3d
Fix completion on $nu to show correct menus (#8919)
I'm still new to nushell and Rust, so please let me know if there are
any omissions and/or mistakes.

# Description

fixed #8863
`$nu` completion shows wrong completion menus at this time.
This PR fixes the problem to show the correct ones.

# User-Facing Changes

Users can use the correct menus on `$nu` completion like this
[recording](https://asciinema.org/a/KCwfpdAoMFsQODFBnb3NwmufC).

# Tests + Formatting

```
$ use toolkit.nu
$ toolkit check pr

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

# After Submitting

nothing
2023-04-26 09:15:27 -05:00
WindSoilder
5733a13409
support blink cursor, and fix underscore's cursorshape (#8990)
# Description
Close: #8988

Thanks to new crossterm version, nushell can support blink cursor shape.
It can be config with the following value:
1. blink_block
2. blink_line
3. blink_underscore

And original block, line, underscore will be steady. It also fixes wrong
shape of `underscore`.

# User-Facing Changes
Here is a little breaking change, before the change: `line` cursor shape
is blinking line, but after this pr, it will be `steady line`. To make a
blink line, we need to change the value to `blink_line`.

But I think it's ok, because after the change, we have a good naming
convention about the name of shape

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `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-04-26 08:14:50 -05:00
Steven Xu
66b5931438
fix: set the initial repl cursor pos, fixes #8943 (#8955)
# Description
Set the initial repl cursor pos, so running `commandline --insert`
inserts at the current cursor position of the input buffer.



Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
2023-04-26 01:08:11 +02:00
Stefan Holderbach
7d6a32c5f8
Bump to 0.79.1 dev version (#8998)
# Description

For development or hotfixes
2023-04-26 01:05:23 +02:00
Stefan Holderbach
a1b7261121
Bump version for 0.79.0 release (#8980) 2023-04-25 23:06:17 +03:00
Stefan Holderbach
5a4b6f0f7f
Pin reedline to 0.19.0 release (#8996)
# Description
See release notes:

https://github.com/nushell/reedline/releases/tag/v0.19.0
2023-04-25 20:58:33 +02:00
Darren Schroeder
29256b161c
fix reedline breaking changes due to PR562 (#8921)
# Description
This PR fixes the breaking changes to the reedline API due to
https://github.com/nushell/reedline/pull/562. It does not implement any
new features but just gets nushell back to compiling again.

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `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-04-18 08:35:10 -05:00
JT
32f098d91d
Hopefully speedup startup (#8913)
# Description

Trying a few different things to hopefully speedup startup a bit. I'm
seeing some improvement on my box for the profiles I have, but the data
I'm seeing is noisy.

- Remove allocations in a few places where we created vec's but could
use iterators
- Pre-allocate space for blocks based on the lite block
- Removed a few extra clones

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

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `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-04-18 20:19:08 +12:00
goldfish
45d33e70db
Change NU_LIB_DIRS not to depend on $nu.config-path (#8887) 2023-04-14 23:16:00 +03:00
WindSoilder
9b35d59023
Update crossterm version to 0.26 (#8623)
# Description

This pr is a companion to https://github.com/nushell/reedline/pull/560

Fortunally, we don't need to change too much nushell code.

## Additional note about lscolor dependency
https://github.com/sharkdp/lscolors/pull/58~~
lscolor is using 0.26 for now
2023-04-14 22:14:57 +02:00
Jelle Besseling
8ddebcb932
Add $env.CURRENT_FILE variable (#8861)
Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-04-13 23:33:29 +03:00
JT
8ee52b6ee1
Relax the closure syntax, highlight differently (#8846)
# Description

This relaxes the closure syntax so that `||` is no longer required. This
allows for `ls | each { $in.name }` for example.

I've gone ahead and changed the syntax highlighting so that blocks and
closures are distinct for now.

# User-Facing Changes

Removes `||` requirement for closures.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `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-04-12 05:21:52 +12:00
Stefan Holderbach
57510f2fd2
Move CLI related commands to nu-cli (#8832)
# Description

Part of the larger cratification effort.

Moves all `reedline` or shell line editor specific commands to `nu-cli`.

## From `nu-cmd-lang`:
- `commandline`
- This shouldn't have moved there. Doesn't directly depend on reedline
but assumes parts in the engine state that are specific to the use of
reedline or a REPL

## From `nu-command`:
- `keybindings` and subcommands
  - `keybindings default`
  - `keybindings list`
  - `keybindings listen`
    - very `reedline` specific
- `history`
  - needs `reedline`
- `history session`

## internal use
Instead of having a separate `create_default_context()` that calls
`nu-command`'s `create_default_context()`, I added a `add_cli_context()`
that updates an `EngineState`


# User-Facing Changes

None

## Build time comparison

`cargo build --timings` from a `cargo clean --profile dev`

### total
main: 64 secs
this: 59 secs

### `nu-command` build time

branch | total| codegen | fraction  
---|---|---|---
main | 14.0s | 6.2s | (44%)
this | 12.5s | 5.5s | (44%)

`nu-cli` depends on `nu-command` at the moment.
Thus it is built during the code-gen phase of `nu-command` (on 16
virtual cores)

# Tests + Formatting

I removed the `test_example()` facilities for now as we had not run any
of the commands in an `Example` test and importing the right context for
those tests seemed more of a hassle than the duplicated
`test_examples()` implementations in `nu-cmd-lang` and `nu-command`
2023-04-10 10:56:47 +12:00
JT
9e3d6c3bfd
Only add the std lib files once (#8830)
# Description

We were seeing duplicate entries for the std lib files, and this PR
addresses that. Each file should now only be added once.

Note: they are still parsed twice because it's hard to recover the
module from the output of `parse` but a bit of clever hacking in a
future PR might be able to do that.

# User-Facing Changes

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

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `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-04-10 08:55:47 +12:00
Michael Angerman
60e6ea5abd
remove nu_cli crate dependency from nu_std (#8807)
now nu_std only depends on nu_parser, nu_protocol and miette
and removes the nu_cli dependency

this enables developers moving forward to come along and implement their
own CLI's without having to pull in a redundant nu-cli which will not be
needed for them.

I did this by moving report_error into nu_protocol
which nu_std already has a dependency on anyway....



- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests.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
> ```
2023-04-08 13:53:43 +02:00
Jelle Besseling
e6b196c141
Add $nu.current-exe variable (#8789)
# Description

Part solving #8752

Adds an extra variable to the `nu` table `current-exe` which is the path
to the running shell executable.

# User-Facing Changes

Adds a variable to the `nu` table.

# Tests + Formatting

Tests and formatting have been run. No new test added

# After Submitting

I could add documentation for this if wanted

Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
2023-04-07 13:51:09 -05:00
Jakub Žádník
1b677f167e
Remove old alias implementation (#8797) 2023-04-07 21:09:38 +03:00
JT
aded2c1937
Refactor to support multiple parse errors (#8765)
# Description

This is a pretty heavy refactor of the parser to support multiple parser
errors. It has a few issues we should address before landing:

- [x] In some cases, error quality has gotten worse `1 / "bob"` for
example
- [x] if/else isn't currently parsing correctly
- probably others

# User-Facing Changes

This may have error quality degradation as we adjust to the new error
reporting mechanism.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.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-04-07 12:35:45 +12:00
dependabot[bot]
a29b61bd4f
Bump miette from 5.6.0 to 5.7.0 (#8720) 2023-04-06 20:39:54 +00:00
JT
56efbd7de9
Add IDE support (#8745)
# Description

This adds a set of new flags on the `nu` binary intended for use in
IDEs. Here is the set of supported functionality so far:

* goto-def - go to the definition of a variable or custom command
* type hints - see the inferred type of variables
* check - see the errors in the document (currently only one error is
supported)
* hover - get information about the variable or custom command
* complete - get a completion list at the current position

# User-Facing Changes

No changes to the REPL experience. This only impacts the IDE scenario.

# Tests + Formatting

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

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

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect` to check that you're using the standard code
style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-utils/standard_library/tests.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: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2023-04-06 07:34:47 +12:00
StevenDoesStuffs
1134c2f16c
Allow NU_LIBS_DIR and friends to be const (#8538) 2023-04-05 19:56:48 +03:00
Stefan Holderbach
d18cf19a3f
Bump to 0.78.1 development version (#8741)
# Description

either just development or hotfix
2023-04-05 13:36:10 +12:00
Stefan Holderbach
2ec2028637
Bump version to 0.78.0 (#8715)
# Description

Version bump for the `0.78.0`

Start to include the version with our `default_config.nu` and
`default_env.nu`

# Checklist

- [x] reedline
- [ ] release notes
2023-04-04 20:47:00 +02:00
Stefan Holderbach
b84a01cb1d
Pin reedline to 0.18.0 release (#8728)
# Description

see release notes:

https://github.com/nushell/reedline/releases/tag/v0.18.0
2023-04-04 00:23:08 +02:00
Stefan Holderbach
ca4d8008d4
Fix rest of license year ranges (#8727)
# Description

In theory we don't need to include the end of the year range for a
proper MIT license.
2023-04-04 09:03:29 +12:00
Reilly Wood
d8478ca690
Clean up unnecessary macro use (#8607)
Some minor code cleanup.

We've accumulated a few macros over the years that arguably don't need
to be macros. This PR removes 4 macros by either:
1. Inlining the macro
2. Replacing the macro with a local function
3. Replacing the macro with a closure
2023-03-25 20:17:20 +13:00
dependabot[bot]
4a1d12462f
Bump miette from 5.5.0 to 5.6.0 (#8531)
Bumps [miette](https://github.com/zkat/miette) from 5.5.0 to 5.6.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/zkat/miette/blob/main/CHANGELOG.md">miette's
changelog</a>.</em></p>
<blockquote>
<h2>5.6.0 (2023-03-14)</h2>
<h3>Bug Fixes</h3>
<ul>
<li><strong>ci:</strong> configure clippy-specific MSRV (<a
href="b658fc020b">b658fc02</a>)</li>
<li><strong>graphical:</strong> Fix wrong severity of related errors (<a
href="https://redirect.github.com/zkat/miette/issues/234">#234</a>) (<a
href="3497508aa9">3497508a</a>)</li>
<li><strong>atty:</strong> Switch out <code>atty</code> for
<code>is-terminal</code> (<a
href="https://redirect.github.com/zkat/miette/issues/229">#229</a>) (<a
href="443d240f49">443d240f</a>)</li>
</ul>
<h3>Features</h3>
<ul>
<li><strong>protocol:</strong> implement <code>Ord</code> for
<code>Severity</code> (<a
href="https://redirect.github.com/zkat/miette/issues/240">#240</a>) (<a
href="ed486c959d">ed486c95</a>)</li>
</ul>
<p><!-- raw HTML omitted --><!-- raw HTML omitted --></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="78fe18e699"><code>78fe18e</code></a>
chore: Release</li>
<li><a
href="2335b25ee7"><code>2335b25</code></a>
docs: update changelog</li>
<li><a
href="443d240f49"><code>443d240</code></a>
fix(atty): Switch out <code>atty</code> for <code>is-terminal</code> (<a
href="https://redirect.github.com/zkat/miette/issues/229">#229</a>)</li>
<li><a
href="ed486c959d"><code>ed486c9</code></a>
feat(protocol): implement <code>Ord</code> for <code>Severity</code> (<a
href="https://redirect.github.com/zkat/miette/issues/240">#240</a>)</li>
<li><a
href="3497508aa9"><code>3497508</code></a>
fix(graphical): Fix wrong severity of related errors (<a
href="https://redirect.github.com/zkat/miette/issues/234">#234</a>)</li>
<li><a
href="b658fc020b"><code>b658fc0</code></a>
fix(ci): configure clippy-specific MSRV</li>
<li><a
href="ebc61b5cf8"><code>ebc61b5</code></a>
docs: Mention miette::miette! macro under &quot;... in application
code&quot; (<a
href="https://redirect.github.com/zkat/miette/issues/233">#233</a>)</li>
<li><a
href="14f952dc91"><code>14f952d</code></a>
(cargo-release) start next development iteration 5.5.1-alpha.0</li>
<li><a
href="128c0a1fae"><code>128c0a1</code></a>
(cargo-release) start next development iteration 5.5.1-alpha.0</li>
<li>See full diff in <a
href="https://github.com/zkat/miette/compare/miette-derive-v5.5.0...miette-derive-v5.6.0">compare
view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-24 22:55:25 +13:00
JT
2c3aade057
Add pattern matching (#8590)
# Description

This adds `match` and basic pattern matching.

An example:

```
match $x {
  1..10 => { print "Value is between 1 and 10" }
  { foo: $bar } => { print $"Value has a 'foo' field with value ($bar)" }
  [$a, $b] => { print $"Value is a list with two items: ($a) and ($b)" }
  _ => { print "Value is none of the above" }
}
```

Like the recent changes to `if` to allow it to be used as an expression,
`match` can also be used as an expression. This allows you to assign the
result to a variable, eg) `let xyz = match ...`

I've also included a short-hand pattern for matching records, as I think
it might help when doing a lot of record patterns: `{$foo}` which is
equivalent to `{foo: $foo}`.

There are still missing components, so consider this the first step in
full pattern matching support. Currently missing:
* Patterns for strings
* Or-patterns (like the `|` in Rust)
* Patterns for tables (unclear how we want to match a table, so it'll
need some design)
* Patterns for binary values
* And much more

# User-Facing Changes

[see above]

# Tests + Formatting

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

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

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

> **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-03-24 14:52:01 +13:00
Darren Schroeder
1e39a1a7a3
fixes the ability to have multiple modifiers on keybindings (#8579)
# Description

This PR fixes a bug that prevented you from having multiple modifiers on
your keybindings.

TODO:
- The docs need to be fixed too
https://www.nushell.sh/book/line_editor.html#keybindings.
(https://github.com/nushell/nushell.github.io/pull/840)
- I think reedline needs to be changed to show this too since it
provides the list of available modifiers.
(https://github.com/nushell/reedline/pull/559)

Now you can do something like this where `shift` and `alt` are combined
with an underscore.
```
  {
    name: fuzzy_history_fzf
    modifier: shift_alt
    keycode: char_r
    mode: [emacs , vi_normal, vi_insert]
    event: {
blah
}
```
Here's the list of available combinations
```rust
        "control" => KeyModifiers::CONTROL,
        "shift" => KeyModifiers::SHIFT,
        "alt" => KeyModifiers::ALT,
        "none" => KeyModifiers::NONE,
        "shift_alt" | "alt_shift" => KeyModifiers::SHIFT | KeyModifiers::ALT,
        "control_shift" | "shift_control" => KeyModifiers::CONTROL | KeyModifiers::SHIFT,
        "control_alt" | "alt_control" => KeyModifiers::CONTROL | KeyModifiers::ALT,
        "control_alt_shift" | "control_shift_alt" => {
            KeyModifiers::CONTROL | KeyModifiers::ALT | KeyModifiers::SHIFT
        }
```

# User-Facing Changes

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

# Tests + Formatting

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

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

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

> **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-03-23 07:07:14 -05:00
Steven Xu
b9858ea8f8
fix: set repl_buffer_state to the REPL buffer after the `pre_execut… (#8560)
…ion` hook


# Description

Previously when a `executehostcommand` shortcut calls `commandline`, to
get the current command line, it's incorrectly set to the value of
`executehostcommand` `cmd`.

This fixes the regression (due to #8207), so it's correctly set to
what's in the REPL buffer.

# User-Facing Changes

# Tests + Formatting

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

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

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

> **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-03-22 06:43:25 -05:00
dependabot[bot]
9c6bfc0be9
Bump rstest from 0.16.0 to 0.17.0 (#8534) 2023-03-20 17:27:29 +00:00
Steven Xu
1d3f6105f5
feat: add a command_not_found hook (#8314)
# Description
Add a `command_not_found` function to `$env.config.hooks`. If this
function outputs a string, then it's included in the `help`.

An example hook on *Arch Linux*, to find packages that contain the
binary, looks like:

```nushell
let-env config = {
  # ...
  hooks: {
    command_not_found: {
      |cmd_name| (
        try {
          let pkgs = (pkgfile --binaries --verbose $cmd_name)
          (
            $"(ansi $env.config.color_config.shape_external)($cmd_name)(ansi reset) " +
            $"may be found in the following packages:\n($pkgs)"
          )
        } catch {
          null
        }
      )
    }
    # ...
```

# User-Facing Changes
- Add a `command_not_found` function to `$env.config.hooks`.

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-03-20 17:05:22 +13:00
Darren Schroeder
ef7fbf4bf9
Revert "Allow NU_LIBS_DIR and friends to be const" (#8501)
Reverts nushell/nushell#8310

In anticipation that we may want to revert this PR. I'm starting the
process because of this issue.

This stopped working
```
let-env NU_LIB_DIRS = [
    ($nu.config-path | path dirname | path join 'scripts')
    'C:\Users\username\source\repos\forks\nu_scripts'
    ($nu.config-path | path dirname)
]
```
You have to do this now instead.
```
const NU_LIB_DIRS = [
    'C:\Users\username\AppData\Roaming\nushell\scripts'
    'C:\Users\username\source\repos\forks\nu_scripts'
    'C:\Users\username\AppData\Roaming\nushell'
]
```

In talking with @kubouch, he was saying that the `let-env` version
should keep working. Hopefully it's a small change.
2023-03-17 09:33:24 -05:00
StevenDoesStuffs
400a9d3b1e
Allow NU_LIBS_DIR and friends to be const (#8310)
# Description

Allow NU_LIBS_DIR and friends to be const they can be updated within the
same parse pass. This will allow us to remove having multiple config
files eventually.

Small implementation detail: I've changed `call.parser_info` to a
hashmap with string keys, so the information can have names rather than
indices, and we don't have to worry too much about the order in which we
put things into it.

Closes https://github.com/nushell/nushell/issues/8422

# User-Facing Changes

In a single file, users can now do stuff like
```
const NU_LIBS_DIR = ['/some/path/here']
source script.nu
```
and the source statement will use the value of NU_LIBS_DIR declared the
line before.

Currently, if there is no `NU_LIBS_DIR` const, then we fallback to using
the value of the `NU_LIBS_DIR` env-var, so there are no breaking changes
(unless someone named a const NU_LIBS_DIR for some reason).


![2023-03-04-014103_hyprshot](https://user-images.githubusercontent.com/13265529/222885263-135cdd0d-7884-438b-b2ed-c3979fa44463.png)

# Tests + Formatting

~~TODO: write tests~~ Done

# After Submitting

~~TODO: update docs~~ Will do when we update default_env.nu/merge
default_env.nu into default_config.nu.
2023-03-17 07:23:29 -05:00
JT
2d41613039
bump to 0.77.2 (#8496)
# Description

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

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

# User-Facing Changes

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

# Tests + Formatting

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

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

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

> **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-03-17 21:29:15 +13:00
Steven Xu
b2a557d4ed
fix: fix commandline when called with no arguments (#8207)
# Description

This fixes the `commandline` command when it's run with no arguments, so
it outputs the command being run. New line characters are included.

This allows for:

- [A way to get current command inside pre_execution hook · Issue #6264
· nushell/nushell](https://github.com/nushell/nushell/issues/6264)
- The possibility of *Atuin* to work work *Nushell*. *Atuin* hooks need
to know the current repl input before it is run.

# User-Facing Changes

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-03-16 17:45:35 -05:00
Reilly Wood
21b84a6d65
Optional members in cell paths: Attempt 2 (#8379)
This is a follow up from https://github.com/nushell/nushell/pull/7540.
Please provide feedback if you have the time!

## Summary

This PR lets you use `?` to indicate that a member in a cell path is
optional and Nushell should return `null` if that member cannot be
accessed.

Unlike the previous PR, `?` is now a _postfix_ modifier for cell path
members. A cell path of `.foo?.bar` means that `foo` is optional and
`bar` is not.

`?` does _not_ suppress all errors; it is intended to help in situations
where data has "holes", i.e. the data types are correct but something is
missing. Type mismatches (like trying to do a string path access on a
date) will still fail.

### Record Examples

```bash

{ foo: 123 }.foo # returns 123

{ foo: 123 }.bar # errors
{ foo: 123 }.bar? # returns null

{ foo: 123 } | get bar # errors
{ foo: 123 } | get bar? # returns null

{ foo: 123 }.bar.baz # errors
{ foo: 123 }.bar?.baz # errors because `baz` is not present on the result from `bar?`
{ foo: 123 }.bar.baz? # errors
{ foo: 123 }.bar?.baz? # returns null
```

### List Examples
```
〉[{foo: 1} {foo: 2} {}].foo
Error: nu:🐚:column_not_found

  × Cannot find column
   ╭─[entry #30:1:1]
 1 │ [{foo: 1} {foo: 2} {}].foo
   ·                    ─┬  ─┬─
   ·                     │   ╰── cannot find column 'foo'
   ·                     ╰── value originates here
   ╰────
〉[{foo: 1} {foo: 2} {}].foo?
╭───┬───╮
│ 0 │ 1 │
│ 1 │ 2 │
│ 2 │   │
╰───┴───╯
〉[{foo: 1} {foo: 2} {}].foo?.2 | describe
nothing

〉[a b c].4? | describe
nothing

〉[{foo: 1} {foo: 2} {}] | where foo? == 1
╭───┬─────╮
│ # │ foo │
├───┼─────┤
│ 0 │   1 │
╰───┴─────╯
```

# Breaking changes

1. Column names with `?` in them now need to be quoted.
2. The `-i`/`--ignore-errors` flag has been removed from `get` and
`select`
1. After this PR, most `get` error handling can be done with `?` and/or
`try`/`catch`.
4. Cell path accesses like this no longer work without a `?`:
```bash
〉[{a:1 b:2} {a:3}].b.0
2
```
We had some clever code that was able to recognize that since we only
want row `0`, it's OK if other rows are missing column `b`. I removed
that because it's tricky to maintain, and now that query needs to be
written like:


```bash
〉[{a:1 b:2} {a:3}].b?.0
2
```

I think the regression is acceptable for now. I plan to do more work in
the future to enable streaming of cell path accesses, and when that
happens I'll be able to make `.b.0` work again.
2023-03-15 20:50:58 -07:00
Stefan Holderbach
1701303279
Bump to 0.77.1 development version (#8453)
# Description

Either to be used in an emergency point release or to indicate
development builds in the `version` command
2023-03-14 23:26:08 +01:00
Stefan Holderbach
fd09609b44
Bump version to 0.77.0 (#8410) 2023-03-14 20:46:42 +02:00
Stefan Holderbach
c7583ecdb7
Pin to reedline 0.17 (#8441)
# Description

See release notes:

https://github.com/nushell/reedline/releases/tag/v0.17.0
2023-03-14 00:04:36 +01:00
Stefan Holderbach
4eec4a27c7
Pin to nu-ansi-term 0.47 (#8440)
# Description

Update reedline to a commit that uses the same version as we share types

# User-Facing Changes

(-)

# Tests + Formatting

Build check
2023-03-13 23:38:18 +01:00
Stefan Holderbach
a52386e837
Box ShellError in Value::Error (#8375)
# Description

Our `ShellError` at the moment has a `std::mem::size_of<ShellError>` of
136 bytes (on AMD64). As a result `Value` directly storing the struct
also required 136 bytes (thanks to alignment requirements).

This change stores the `Value::Error` `ShellError` on the heap.

Pro:
- Value now needs just 80 bytes
- Should be 1 cacheline less (still at least 2 cachelines)

Con:
- More small heap allocations when dealing with `Value::Error`
  - More heap fragmentation
  - Potential for additional required memcopies

# Further code changes

Includes a small refactor of `try` due to a type mismatch in its large
match.

# User-Facing Changes

None for regular users.

Plugin authors may have to update their matches on `Value` if they use
`nu-protocol`

Needs benchmarking to see if there is a benefit in real world workloads.
**Update** small improvements in runtime for workloads with high volume
of values. Significant reduction in maximum resident set size, when many
values are held in memory.

# Tests + Formatting
2023-03-12 09:57:27 +01:00
Antoine Stevan
4e78f3649b
FEATURE: add the startup time to $nu (#8353)
# Description
in https://github.com/nushell/nushell/issues/8311 and the discord
server, the idea of moving the default banner from the `rust` source to
the `nushell` standar library has emerged 😋

however, in order to do this, one need to have access to all the
variables used in the default banner => all of them are accessible
because known constants, except for the startup time of the shell, which
is not anywhere in the shell...

#### this PR adds exactly this, i.e. the new `startup_time` to the `$nu`
variable, which is computed to have the exact same value as the value
shown in the banner.

## the changes
in order to achieve this, i had to
- add `startup_time` as an `i64` to the `EngineState` => this is, to the
best of my knowledge, the easiest way to pass such an information around
down to where the banner startup time is computed and where the `$nu`
variable is evaluated
- add `startup-time` to the `$nu` variable and use the `EngineState`
getter for `startup_time` to show it as a `Value::Duration`
- pass `engine_state` as a `&mut`able argument from `main.rs` down to
`repl.rs` to allow the setter to change the value of `startup_time` =>
without this, the value would not change and would show `-1ns` as the
default value...
- the value of the startup time is computed in `evaluate_repl` in
`repl.rs`, only once at the beginning, and the same value is used in the
default banner 👌

# User-Facing Changes
one can now access to the same time as shown in the default banner with
```bash
$nu.startup-time
```

# Tests + Formatting
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🟢 `cargo test --workspace`

# After Submitting
```
$nothing
```
2023-03-09 14:18:58 -06:00
StevenDoesStuffs
7e949595bd
Add is-interactive and is-login to NuVariable and allow running scripts with -i (#8306)
Add two rows in `$nu`, `$nu.is-interactive` and `$nu.is-login`, which
are true when nu is run in interactive and login mode respectively.

The `-i` flag now behaves a bit more like that of bash's, where the any
provided command or file is run without REPL but in "interactive mode".
This should entail sourcing interactive-mode config files, but since we
are planning on overhauling the config system soon, I'm holding off on
that. For now, all `-i` does is set `$nu.is-interactive` to be true.

About testing, I can't seem to find where cli-args get tested, so I
haven't written any new tests for this. Also I don't think there are any
docs that need updating. However if I'm wrong please tell me.
2023-03-08 20:59:33 -06:00
Stefan Holderbach
f7b8f97873
Document and critically review ShellError variants - Ep. 2 (#8326)
Continuation of #8229 

# Description

The `ShellError` enum at the moment is kind of messy. 

Many variants are basic tuple structs where you always have to reference
the implementation with its macro invocation to know which field serves
which purpose.
Furthermore we have both variants that are kind of redundant or either
overly broad to be useful for the user to match on or overly specific
with few uses.

So I set out to start fixing the lacking documentation and naming to
make it feasible to critically review the individual usages and fix
those.
Furthermore we can decide to join or split up variants that don't seem
to be fit for purpose.

**Everyone:** Feel free to add review comments if you spot inconsistent
use of `ShellError` variants.

- Name fields of `SE::IncorrectValue`
- Merge and name fields on `SE::TypeMismatch`
- Name fields on `SE::UnsupportedOperator`
- Name fields on `AssignmentRequires*` and fix doc
- Name fields on `SE::UnknownOperator`
- Name fields on `SE::MissingParameter`
- Name fields on `SE::DelimiterError`
- Name fields on `SE::IncompatibleParametersSingle`

# User-Facing Changes

(None now, end goal more explicit and consistent error messages)

# Tests + Formatting

(No additional tests needed so far)
2023-03-06 11:31:07 +01:00
Reilly Wood
f93033c20b
Fix CPU usage info in sys (#8321)
Closes #8264. This PR does a few things to fix the `usage` column in
`sys.cpu`:

1. Sleep a while (~400ms) between calls to `sys.refresh_cpu()`, [as
required by
`sysinfo`](https://docs.rs/sysinfo/latest/sysinfo/trait.SystemExt.html#method.refresh_cpu)
2. Change `sys` to return a `LazyRecord` (so you can do things like `sys
| get host` instantly without waiting for CPU info)
3. Update our `sysinfo` dependency to [fix CPU usage calculations on
Linux](https://github.com/GuillaumeGomez/sysinfo/pull/946)

CPU usage is no longer always reported as zero:


![image](https://user-images.githubusercontent.com/26268125/222929775-5e9cbe18-95d9-4ecb-baf8-1e843f5c7086.png)
2023-03-04 14:48:34 -08:00
Jérémy Audiger
b9c78a05aa
Resolve Clippy warnings inside tests. (#8315)
# Description

Command: `cargo clippy --workspace --all-targets`

Resolve those warnings:

```
warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> crates/nu-parser/tests/test_parser.rs:86:59
   |
86 |             compare_rhs_binaryOp(test_tag, &expected_val, &observed_val);
   |                                                           ^^^^^^^^^^^^^ help: change this to: `observed_val`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default

warning: `assert!(false, ..)` should probably be replaced
   --> crates/nu-cli/src/completions/command_completions.rs:319:17
    |
319 |                 assert!(false, "Merge delta has failed: {}", err);
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!(..)` or `unreachable!(..)`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
    = note: `#[warn(clippy::assertions_on_constants)]` on by default

warning: 1 warning emitted

warning: `assert!(false, ..)` should probably be replaced
   --> crates/nu-cli/src/completions/completer.rs:600:13
    |
600 |             assert!(false, "Error merging delta: {:?}", err);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!(..)` or `unreachable!(..)`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants

warning: length comparison to zero
   --> crates/nu-cli/src/completions/completer.rs:620:24
    |
620 |             assert_eq!(result.len() > 0, has_result, "line: {}", line);
    |                        ^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!result.is_empty()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
    = note: `#[warn(clippy::len_zero)]` on by default

warning: equality checks against true are unnecessary
   --> crates/nu-cli/src/completions/completer.rs:632:33
    |
632 |                     .filter(|x| *x == true)
    |                                 ^^^^^^^^^^ help: try simplifying it as shown: `*x`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_comparison
    = note: `#[warn(clippy::bool_comparison)]` on by default

    Checking nu v0.76.1 (/home/jaudiger/Development/git-repositories/jaudiger/nushell)
warning: 4 warnings emitted

warning: the borrowed expression implements the required traits
  --> crates/nu-command/tests/commands/cp.rs:26:40
   |
26 |         let first_hash = get_file_hash(&test_file.display());
   |                                        ^^^^^^^^^^^^^^^^^^^^ help: change this to: `test_file.display()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
   = note: `#[warn(clippy::needless_borrow)]` on by default

warning: the borrowed expression implements the required traits
   --> crates/nu-command/tests/commands/cp.rs:178:13
    |
178 |             &jonathans_expected_copied_dir
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `jonathans_expected_copied_dir`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: the borrowed expression implements the required traits
   --> crates/nu-command/tests/commands/cp.rs:182:13
    |
182 |             &andres_expected_copied_dir
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `andres_expected_copied_dir`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: the borrowed expression implements the required traits
   --> crates/nu-command/tests/commands/cp.rs:186:13
    |
186 |             &yehudas_expected_copied_dir
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `yehudas_expected_copied_dir`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: 4 warnings emitted
```

# User-Facing Changes

None.

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-03-04 14:58:20 +01:00
JT
6148314dcd
print pipeline contents in print (#8305)
# Description

Have `print` print it's input, so it's easier to print a pipeline (esp
after we land #8292 and related)

# User-Facing Changes

`print` will now print its input, if there are no args given

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-03-04 11:31:01 +13:00
Doru
1a62d87a42
Make the default prompt play nice with basic fonts (#8080)
# Description
This commit changes the `PROMPT_INDICATOR` and
`PROMPT_INDICATOR_VI_NORMAL` in the default_env and sample_login files.
It also changes its missing fallback in the prompt.rs file.

This has the intention of making the default prompt friendlier when
dealing with basic terminals that may not support displaying a huge
range of the Unicode standard, or users who don't want to get out of
their way to install custom fonts for their terminals. It's also
nicer/more balanced on the eyes, to me, and brings it in line with the
logo of nushell `nu>`.

# User-Facing Changes
New installations of nushell will have > as the default prompt
indicator, and running `config reset` will also change it. This might be
confusing for a few seconds, it could be minor enough that it just feels
slightly off. Anyone who has, for some reason, unset the
PROMPT_INDICATOR variable, or set it to $nothing, will also receive the
`>` treatment.

Users running on basic terminals (like cmd.exe on Windows 10) should no
longer face font issues with the default basic prompt.

# Drawbacks
The Unicode arrow is pretty cool. And it predates many of us. Maybe it's
worth keeping. One argument I could see, and mildly disagree with, is
that it might make users lean towards installing a modern font for their
terminal which will would have good consequences in the future.
2023-03-02 13:59:32 +13:00
Jérémy Audiger
a5c604c283
Uniformize usage() and extra_usage() message ending for commands helper. (#8268)
# Description

Working on uniformizing the ending messages regarding methods usage()
and extra_usage(). This is related to the issue
https://github.com/nushell/nushell/issues/5066 after discussing it with
@jntrnr

# User-Facing Changes

None.

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-28 21:33:02 -08:00
Reilly Wood
cc7bdebc1c
Switch http to https in banner (#8272)
Changing `http` to `https` in the banner now that `https://nushell.sh`
works: https://github.com/nushell/nushell.github.io/issues/294
2023-02-28 20:32:31 -08:00
Gustavo Maia
c6e2607868
Add Remove welcome message tutorial (#8217)
# Description

Added message sending to docs to how to remove message tutorial:

![welcome
message](https://user-images.githubusercontent.com/67283753/221384655-9218c256-b4d6-44e5-95c6-68c50c235cb7.png)



# User-Facing Changes

- Easy to find how to remove Welcome Message


Fixes #8216  issue
2023-02-27 19:49:50 +13:00
alesito85
7c285750c7
Fixes autocomplete when using sudo (#8094)
# Description

This PR addresses issue #2047 in order to enable autocomplete
functionality when using sudo for executing commands. I'e done a couple
of auxiliary checks such as ignoring whitespace and the last pipe in
order to determine the last command.

# User-Facing Changes

The only user facing change should be the autocomplete working.

# Tests + Formatting

All tests and formatting pass.

# Screenshots

<img width="454" alt="image"
src="https://user-images.githubusercontent.com/4399118/219404037-6cce4358-68a9-42bb-a09b-2986b10fa6cc.png">

# Suggestions welcome

I still don't know the in's and out's if nushell very well, any
suggestions for improvements are welcome.
2023-02-24 15:05:36 -08:00
Henry Jetmundsen
253b223e65
pipe binary data to external commands (#8058)
Fixes #7615 

# Description

When calling external commands, we create a table from the pipeline data
to handle external commands expecting paginated input. When a binary
value is made into a table, we convert the vector of bytes representing
the binary bytes into a pretty formatted string. This results in the
pretty formatted string being sent to external commands instead of the
actual binary bytes. By checking whether the stdout of the call is being
redirected, we can decide whether to send the raw binary bytes or the
pretty formatted output when creating a table command.

# User-Facing Changes

When passing binary values to external commands, the external command
will receive the actual bytes instead of the pretty printed string. Use
cases that don't involve piping a binary value into an external command
are unchanged.


![new_behavior](https://user-images.githubusercontent.com/32406734/218349172-24cd12f2-d563-4957-bdf1-6aa804b174b2.png)

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-24 21:39:52 +01:00
Ryan Devenney
d34a2c353f
files and directory completions now use ascending ordering rather than Levenshtein. #8023 (#8085)
# Description

This change sorts completions for files and directories by the ascending
ordering method, related to issue:
[#8023](https://github.com/nushell/nushell/issues/8023)

Currently the Suggestions are being sorted twice, so it's now following
the convention from `completion/base.rs` to match on the
`self.get_sort_by()` result.

# User-Facing Changes

Previously the suggestions were being sorted by the Levenshtein method:
```
/home/rdevenney/projects/open_source/nushell| cd
src/                wix/                docs/               tests/
assets/             crates/             docker/             images/
target/             benches/            pkg_mgrs/           .git/
.cargo/             .github/
```

Now when you tab for autocompletions, they show up in ascending
alphabetical order as shown below (with hidden files/folders at the
end).
```
/home/rdevenney/projects/open_source/nushell| cd
assets/             benches/            crates/             docker/
docs/               images/             pkg_mgrs/           src/
target/             tests/              wix/                .cargo/
.git/               .github/
```

And when you've already typed a bit of the path:
```
/home/rdevenney/projects/open_source/nushell| cd crates/nu
crates/nu-cli/                   crates/nu-color-config/          crates/nu-command/
crates/nu-engine/                crates/nu-explore/               crates/nu-glob/
crates/nu-json/                  crates/nu-parser/                crates/nu-path/
crates/nu-plugin/                crates/nu-pretty-hex/            crates/nu-protocol/
crates/nu-system/                crates/nu-table/                 crates/nu-term-grid/
crates/nu-test-support/          crates/nu-utils/                 crates/nu_plugin_custom_values/
crates/nu_plugin_example/        crates/nu_plugin_formats/        crates/nu_plugin_gstat/
crates/nu_plugin_inc/            crates/nu_plugin_python/         crates/nu_plugin_query/
```

And another for when there are files and directories present:
```
/home/rdevenney/projects/open_source/nushell/crates/nu-cli/src| nvim                              02/16/2023 08:22:16 AM
commands.rs          completions/         config_files.rs      eval_file.rs
lib.rs               menus/               nu_highlight.rs      print.rs
prompt.rs            prompt_update.rs     reedline_config.rs   repl.rs
syntax_highlight.rs  util.rs              validation.rs
```

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-22 13:03:48 +00:00
Stefan Holderbach
95ec2fcce7
Update to 0.76.1 version for development (#8161)
# Description

For tracking in `version` for bug reports during development. Might be
used for an urgent hotfix if necessary.
2023-02-21 23:21:39 +00:00
Stefan Holderbach
bc38a6a795
Bump version for 0.76.0 release (#8121)
Before landing:

- [x] `reedline 0.16.0` is out and pinned.
- [x] all fixes and features necessary are landed.

In the meantime:

- [ ] feed the release notes with relevant features and breaking changes
2023-02-21 20:46:29 +00:00
Stefan Holderbach
ca09dbbbee
Pin reedline to 0.16.0 (#8142)
# Description

See release notes:
https://github.com/nushell/reedline/releases/tag/v0.16.0

# User-Facing Changes

Only internal

# Tests + Formatting

(-)
2023-02-20 21:44:04 +00:00
dependabot[bot]
527c44ed84
Bump sysinfo from 0.27.7 to 0.28.0 (#8132)
Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.27.7
to 0.28.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md">sysinfo's
changelog</a>.</em></p>
<blockquote>
<h1>0.28.0</h1>
<ul>
<li>Linux: Fix name and CPU usage for processes tasks.</li>
<li>unix: Keep all users, even &quot;not real&quot; accounts.</li>
<li>Windows: Use SID for Users ID.</li>
<li>Fix C API.</li>
<li>Disable default cdylib compilation.</li>
<li>Add <code>serde</code> feature to enable serialization.</li>
<li>Linux: Handle <code>Idle</code> state in
<code>ProcessStatus</code>.</li>
<li>Linux: Add brand and name of ARM CPUs.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a
href="https://github.com/GuillaumeGomez/sysinfo/commits">compare
view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-19 20:58:07 -06:00
Jakub Žádník
f3ee8b50e3
Revert #7779 (enables back subcommand completions) (#8102)
# Description

Reverts the PR #7779 which breaks subcommand completions. The issues
#7648 and #7754 thus still need fixing.

This reverts commit 8acced5.

# User-Facing Changes

Enables subcommand completions.

Unfortunately, also brings back the completion panic if alias is shorter
than the command name.

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-18 17:38:29 +00:00
JT
ade7bde813
Bare word improvements (#8066)
# Description

This does two fixes for bare words:

* It changes completions for paths to wrap a path with backticks if it
starts with a number. This helps bare words that start with numbers be
separate from unit values
* It allows bare words wrapped with backticks to be the name of a
command. Backtick values in command positions are no longer treated as
strings

# User-Facing Changes

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

# Tests + Formatting

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

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

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

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-16 02:30:56 +00:00
dependabot[bot]
0a9d14fcb3
Bump rstest from 0.15.0 to 0.16.0 (#8064)
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps [rstest](https://github.com/la10736/rstest) from 0.15.0 to 0.16.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/la10736/rstest/releases">rstest's
releases</a>.</em></p>
<blockquote>
<h2>0.16.0</h2>
<p>Use values expression to define test names.</p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/la10736/rstest/blob/master/CHANGELOG.md">rstest's
changelog</a>.</em></p>
<blockquote>
<h2>[0.16.0] 2022/11/27</h2>
<h3>Changed</h3>
<ul>
<li>Show <code>TEST START</code> banner only when trace some argument:
See <a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/158">#158</a>
for details.</li>
<li>Add values to test name: See <a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/160">#160</a>
for details.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>Updated test fixtures to 1.64.0 compiler's error messages.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="d7ff088126"><code>d7ff088</code></a>
Update checkout list</li>
<li><a
href="4386575950"><code>4386575</code></a>
Version 0.16.0 chengelog</li>
<li><a
href="41749a881e"><code>41749a8</code></a>
Fix clippy warning</li>
<li><a
href="daaddde1a0"><code>daaddde</code></a>
Bump to 0.16.0 version and upgrade dependency</li>
<li><a
href="576768e4b3"><code>576768e</code></a>
Fixed dev dependency in rstest_macros</li>
<li><a
href="a6eb3a96cb"><code>a6eb3a9</code></a>
Update rstest_test version</li>
<li><a
href="4a18dd0bd1"><code>4a18dd0</code></a>
Update version</li>
<li><a
href="29648832ce"><code>2964883</code></a>
Update dependency version</li>
<li><a
href="5ad7e3fd61"><code>5ad7e3f</code></a>
<a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/160">#160</a>
Add test for module annotation</li>
<li><a
href="a302be019f"><code>a302be0</code></a>
<a
href="https://github-redirect.dependabot.com/la10736/rstest/issues/160">#160</a>
Tests fixed and add unit for allow</li>
<li>Additional commits viewable in <a
href="https://github.com/la10736/rstest/compare/0.15.0...0.16.0">compare
view</a></li>
</ul>
</details>
<br />


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

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

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

---

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

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


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 02:34:09 +00:00