In the spirit of #9509 we are changing the visibility of the bits
commands
to align with the way they are correctly done in the bytes commands...
Thanks to @sholderbach for pointing out this nice improvement
to me in my PR earlier in the day...
```rust
mod and;
mod bits_;
mod not;
mod or;
mod rotate_left;
mod rotate_right;
mod shift_left;
mod shift_right;
mod xor;
```
- improves usability of datetime's in displayed text
-
# Description
Creates a config point for specifying long / short date time formats.
Defaults to humanized as we have today.
Provides for adding strftime formats into config.nu such as:
```nu
datetime_format: {
normal: "%Y-%m-%d %H:%M:%S"
table: "%Y-%m-%d"
}
```
Example:
```bash
> $env.config.datetime_format
┏━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ normal ┃ %a, %d %b %Y %H:%M:%S %z ┃
┃ table ┃ %m/%d/%y %I:%M:%S%p ┃
┗━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━┛
> let a = (date now)
> echo $a
Thu, 22 Jun 2023 10:21:23 -0700
> echo [$a]
┏━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ 0 ┃ 06/22/23 10:21:23AM ┃
┗━━━┻━━━━━━━━━━━━━━━━━━━━━┛
```
# User-Facing Changes
Any place converting a datetime to a user displayed value should be
impacted.
# Tests + Formatting
- `cargo fmt --all -- --check` Done
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` Done
- `cargo test --workspace` Done
- `cargo run -- crates/nu-std/tests/run.nu` Not done - doesn't seem to
work
```bash
> use toolkit.nu # or use an `env_change` hook to activate it automatically
> toolkit check pr
``` - Done
---------
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Co-authored-by: Antoine Stevan <44101798+amtoine@users.noreply.github.com>
# Description
This change adds a new flag to the `str replace` command: `--multiline`,
`-m`. This flag will automatically add the multiline regex flag `(?m)`
to the beginning of the supplied regex, allowing for the `^` and `$`
regex characters to match the beginnings and ends of lines,
respectively.
The main advantage of this addition is to make `str replace` more
closely match sed's default behavior of performing matches per-line with
a simple cli flag as opposed to forcing the user to add the {somewhat
clunky) regex flag themselves. This could be an especially valuable
addition since [`str replace` is listed as an alternative to sed in the
official
documentation](https://www.nushell.sh/book/coming_from_bash.html).
With this change, the following two commands would be functionally
equivalent:
```bash
# bash
printf "non-matching line\n123. one line\n124. another line\n" | sed -r 's/^[0-9]+\. //'
```
```bash
# nu
"non-matching line\n123. one line\n124. another line\n" | str replace -am '^[0-9]+\. ' ''
```
both producing the following output:
```
non-matching line
one line
another line
```
# User-Facing Changes
1. Adds a new flag to the `str replace` command: `--multiline`, `-m`.
# Tests + Formatting
I have update the unit tests to test this flag.
<!--
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.
-->
I will submit a PR for all relevant documentation changes as soon as
this PR is approved.
# Description
This PR cleans up the deprecated legacy config options that were
deprecated in nushell version 0.72.0. These are the config points that
were in the root of the config but also duplicated in the nested
structures. For instance `use_ls_colors` was in the root of the config
and also in the `ls.use_ls_colors` nested structure. This was originally
done to preserve backwards compatibility when nested structures were
introduced in the config file.
Here's a list of the legacy config points that were removed.
- `use_ls_colors` - previously replaced with `ls.use_ls_colors`
- `rm_always_trash` - previously replaced with `rm.always_trash`
- `history_file_format` - previously replaced with `history.file_format`
- `sync_history_on_enter` - previously replaced with
`history.sync_on_enter`
- `max_history_size` - previously replaced with `history.max_size`
- `quick_completions` - previously replaced with `completions.quick`
- `partial_completions` - previously replaced with `completions.partial`
- `max_external_completion_results` - previously replaced with
`completions.external.max_results`
- `completion_algorithm` - previously replaced with
`completions.algorithm`
- `case_sensitive_completions` - previously replaced with
`completions.case_sensitive`
- `enable_external_completion` - previously replaced with
`completions.external.enable`
- `external_completer` - previously replaced with
`completions.external.completer`
- `table_mode` - previously replaced with `table.mode`
- `table_index_mode` - previously replaced with `table.index_mode`
- `table_trim` - previously replaced with `table.trim`
- `show_clickable_links_in_ls` - previously replaced with
`ls.clickable_links`
- `cd_with_abbreviations` - previously replaced with `cd.abbreviations`
- `filesize_metric` - previously replaced with `filesize.metric`
- `filesize_format` - previously replaced with `filesize.format`
- `cursor_shape_vi_insert` - previously replaced with
`cursor_shape.vi_insert`
- `cursor_shape_vi_normal` - previously replaced with
`cursor_shape.vi_normal`
- `cursor_shape_emacs` - previously replaced with `cursor_shape.emacs`
Removes log_level from the config since it doesn't do anything any
longer. We moved log-level to a nushell parameter some time ago.
Renames history_isolation to isolation in the config.nu for consistency.
Fixes a couple bugs where values weren't being set in the "//
Reconstruct" sections (history_isolation, table_show_empty).
Reorganized/Moved things around a tiny bit and added a few comments.
# User-Facing Changes
history.histor_isolation is now history.isolation.
If anyone is still using the legacy config points, deprecated since
0.72.0 2022-11-29, their config will break.
# 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.
-->
# Description
make history.max_size bigger so it doesn't eat history
closes#9493
# 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.
-->
related to
- https://github.com/nushell/nushell/pull/9404
# Description
to support our cratification effort and moving non-1.0 commands outside
of the main focus, this PR
- creates a new `nu-cmd-base` crate to hold the common structs, traits
and functions used by all command-related crates
- to start the transition, moves the `input_handler` module from
`nu-command` to `nu-cmd-base`
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- ⚫ `toolkit test`
- ⚫ `toolkit test stdlib`
# After Submitting
```
$nothing
```
# 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.
-->
related to
- https://github.com/nushell/nushell/pull/8544
cc/ @jntrnr @ahkrr
# Description
some of the tests in the `dots.rs` file are a bit hard to read because
some of the paths look like command calls 🤔
in an attempt to making them easier to read, in the tests of `dots.rs`,
this PR
- replaces `file .../` with `not_a_cmd.../` because it's not a call to
the `file` command
- removes the space in `not_a_cmd .../` to see it's not a command call
- adds a bit more `not a cmd` to the last tests, to be consistent with
the other tests
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- ⚫ `toolkit test`
- ⚫ `toolkit test stdlib`
In my view we should revert nushell/nushell#8395 for now
## Potentially inconsistent application of semantic change
#8395 (1d5e7b441b) was loosening the type
coercion rules significantly, to let missing data / void returns that
were either expressed by `PipelineData::Empty` or the `Value::nothing`
be accept by specifically those commands/operations that made use of
`PipelineData::into_iter_strict()`. This could apply the new rules
inconsistently.
## Turning explicit failures into silent continuations
Furthermore the effect of this breaking change to the missing data
semantics could make previous errors into silent failures.
This could either just reduce the effectiveness of teaching error
messages in interactive use:
### Contrived example before
```bash
> cd . | where blah
Error: nu:🐚:only_supports_this_input_type
× Input type not supported.
╭─[entry #13:1:1]
1 │ cd . | where blah
· ──┬──┬
· │ ╰── input type: null
· ╰── only list, binary, raw data or range input data is supported
╰────
```
### ...after, with #8395
```bash
> cd . | where blah
╭────────────╮
│ empty list │
╰────────────╯
```
In rare cases people could already try to rely on catching an error of a
downstream command to actually deal with the missing data, so it would
be a breaking change for their existing code.
## Problem with `PipelineData::into_iter_strict()`
Maybe this makes `_strict` a bit of a misnomer for this particular
iterator construction.
Further we did not actively test the `PipelineData::empty` branch before
![grafik](https://github.com/nushell/nushell/assets/15833959/c377bf1d-d47c-4c25-a342-9a348539f242)
## Parsimonious solution exists
For the motivating issue https://github.com/nushell/nushell/issues/8393
there already exists a fix that makes `ls` more consistent with the type
system by returning an empty `Value::List`
https://github.com/nushell/nushell/pull/8439
<!--
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 fixes the following nightly clippy warnings.
```
warning: you should consider adding a `Default` implementation for `HjsonFormatter<'a>`
--> crates/nu-json/src/ser.rs:700:5
|
700 | / pub fn new() -> Self {
701 | | HjsonFormatter::with_indent(b" ")
702 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
= note: `#[warn(clippy::new_without_default)]` on by default
help: try adding this
|
698 + impl<'a> Default for HjsonFormatter<'a> {
699 + fn default() -> Self {
700 + Self::new()
701 + }
702 + }
|
warning: `nu-json` (lib) generated 1 warning
warning: private item shadows public glob re-export
--> crates/nu-command/src/strings/mod.rs:8:1
|
8 | mod str_;
| ^^^^^^^^^
|
note: the name `str_` in the type namespace is supposed to be publicly re-exported here
--> crates/nu-command/src/strings/mod.rs:17:9
|
17 | pub use str_::*;
| ^^^^^^^
note: but the private item here shadows it
--> crates/nu-command/src/strings/mod.rs:8:1
|
8 | mod str_;
| ^^^^^^^^^
= note: `#[warn(hidden_glob_reexports)]` on by default
warning: incorrect NaN comparison, NaN cannot be directly compared to itself
--> crates/nu-command/src/formats/to/nuon.rs:186:20
|
186 | && val != &f64::NAN
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(invalid_nan_comparisons)]` on by default
help: use `f32::is_nan()` or `f64::is_nan()` instead
|
186 - && val != &f64::NAN
186 + && !val.is_nan()
|
warning: `nu-command` (lib) generated 2 warnings (run `cargo clippy --fix --lib -p nu-command` to apply 1 suggestion)
Compiling nu v0.81.1 (/data/source/nushell)
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> crates/nu-command/tests/commands/rm.rs:392:27
|
392 | dir_to_clean: &test_dir,
| ^^^^^^^^^ help: change this to: `test_dir`
|
= 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: `nu-command` (test "main") generated 1 warning (run `cargo clippy --fix --test "main"` to apply 1 suggestion)
warning: `nu-command` (lib test) generated 2 warnings (2 duplicates)
warning: `nu-json` (lib test) generated 1 warning (1 duplicate)
Finished dev [unoptimized + debuginfo] target(s) in 3.89s
```
# User-Facing Changes
N/A
# 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.
-->
this PR should close#9018
# Description
This PR aims to fix the `input` command with `--suppress-output` on
Windows
This fixes two separates issues :
- Keypresses being duplicated in output due to "Release" event not being
ignored
- "Return" event from entering the `input -s "blah :"` still being in
the event buffer (need to be cleared before reading keypresses)
# Tests + Formatting
- `cargo fmt --all -- --check` ✔️
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` ✔️
- `cargo test --workspace` ✔️
- `cargo run -- crates/nu-std/tests/run.nu` ✔️
# Description
In cases that a path contained 3 or more `.` in succession followed by a
path-separator, the dots would be expanded.
This logic didn't take into account the cases where characters other
than a separator could appear before the `...`, which would lead to
`...` in filenames being expanded.
This PR changes the behavior so that path-segments consisting of 3 or
more dots only will be expanded.
This PR fixes issue #8386
# User-Facing Changes
Paths with filenames like `.../folder.../file.txt` will be correctly
expanded.
# Tests + Formatting
I added tests that cover a number of cases.
# Description
This allows empty pipelines to pass their emptiness through a filter.
This helps fix issues like trying to run a filter on an `ls` in an empty
directory. It also feels a bit more reasonable that a filter filters
what is *there* but doesn't require something to be there.
fixes#8393
# User-Facing Changes
No breaking changes (that I know of). Should allow filtering to be a
little less surprising with emptiness.
# 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.
---------
Co-authored-by: amtoine <stevan.antoine@gmail.com>
# Description
Fixes a small bug with `rm` where names of files which couldn't be
deleted due to error were not printed.
Fixes https://github.com/nushell/nushell/issues/9004
# User-Facing Changes
Slightly different error message than previously. Nothing significant,
though.
The new error message looks like this
```
~/Projects/rust/nushell> rm /proc/1/mem 05/06/2023 01:13:23 PM
Error: nu:🐚:remove_not_possible
× Remove not possible
╭─[entry #3:1:1]
1 │ rm /proc/1/mem
· ─────┬─────
· ╰── Could not delete /proc/1/mem: Operation not permitted (os error 1)
╰────
```
or when using a glob (only showing a single entry for brevity)
```
Error: nu:🐚:remove_not_possible
× Remove not possible
╭─[entry #2:1:1]
1 │ rm --recursive --force --verbose /proc/1/*
· ────┬────
· ╰── Could not delete /proc/1/comm: Operation not permitted (os error 1)
╰────
```
# Tests + Formatting
No new unit tests were added for this change as it is pretty difficult
to test this particular case. However, manual testing was run with the
following commands
```
rm /proc/1/mem
rm --recursive --force --verbose /proc/1/*
```
# After Submitting
N/A
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
closes https://github.com/nushell/nushell/issues/9437
cc/ @Sygmei 😉
# Description
the syntax of *captures* used in `str replace` can be confusing for
people not used to the `regex` syntax.
there is already a capture example in `help str replace`
```bash
Find and replace with fancy-regex
> 'a successful b' | str replace '\b([sS])uc(?:cs|s?)e(ed(?:ed|ing|s?)|ss(?:es|ful(?:ly)?|i(?:ons?|ve(?:ly)?)|ors?)?)\b' '${1}ucce$2'
a successful b
```
but it's really not trivial to understand the *capture* syntax...
this PR adds a simpler example only focused on *captures*
🥳
```bash
Use captures to manipulate the input text
> "abc-def" | str replace "(.+)-(.+)" "${2}_${1}"
def_abc
```
# User-Facing Changes
an example in `help str replace` to understand the syntax of *captures*.
# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- ⚫ `toolkit test`
- ⚫ `toolkit test stdlib`
# After Submitting
```
$nothing
```
Fixes#9448
# Description
Attempts to fix a bug from the linked issue.
# User-Facing Changes
- The editor doesn't crash on wrong commands
# Tests + Formatting
Tests cover my 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
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx
you can also mention related issues, PRs or discussions!
-->
# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.
Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
Added comments to support API docs for the `nu-plugin` crate. Removed a
few items that I'd expect should only be used internally to Nushell from
the documentation and reduced the visibility of some items that did not
need to be public.
# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
There should be no user facing impact.
# 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
> ```
-->
Standard tests run. Additionally numerous doctests were added to the
`nu-plugin` crate.
# 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.
-->
No changes to the website necessary.
# Description
When the directory stack contains only two directories, then std dirs
drop
used to misbehave and (essentially) drop the other directory, instead of
dropping the current directory.
This is fixed by always cd'ing for std dirs drop.
Before:
/tmp〉enter ..
/〉dexit
/〉
After:
/tmp〉enter ..
/〉dexit
/tmp〉
Additionally, I propose to explain the relevant environment variables a
bit
more thoroughly.
# User-Facing Changes
- Fix bug in dexit (std dirs drop) when two directories are remaining
# Tests + Formatting
Added a regression test. Made the existing test easier to understand.
Parse the data from string to json if the `--content-type
"application/json"` flag is used for the request.
Fixes: https://github.com/nushell/nushell/issues/9408
In the issue, the actual data is a string `'{ "query": "{ greeting }"
}'` representing json, and it would match the case `Value::String { val,
.. }`
-------------------------
The example in the issue does set the `content-type` to
`application/json` but sends the body as a string note the `'`.
```
(
::: http post
::: -fer
::: # -H [ "Content-Type" "application/json" ]
::: --content-type "application/json"
::: 'http://127.0.0.1:3000/greetings/hello'
::: '{ "query": "{ greeting }" }'
::: )
```
```
╭─────────┬───────────────────────╮
│ headers │ {record 14 fields} │
│ body │ {"content_type":null} │
│ status │ 200 │
╰─────────┴───────────────────────╯
```
If we send the same request but using actual json as the body, the
Header is set correctly.
```
(
::: http post
::: -fer
::: # -H [ "Content-Type" "application/json" ]
::: --content-type "application/json"
::: 'http://127.0.0.1:3000/greetings/hello'
::: { "query": "{ greeting }" }
::: )
```
```
╭─────────┬─────────────────────────────────────╮
│ headers │ {record 14 fields} │
│ body │ {"content_type":"application/json"} │
│ status │ 200 │
╰─────────┴─────────────────────────────────────╯
```
<!--
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: #5517
- fixes: #9250
For the following commands:
```
ls
# | le
| length
```
I found that it generates a bad lite parsing result:
```
LiteBlock {
block: [
LitePipeline {
commands: [
Command(None, LiteCommand { comments: [], parts: [Span { start: 138600, end: 138602 }] })
]
},
LitePipeline {
commands: [
Command(Some(Span { start: 138610, end: 138611 }),
LiteCommand { comments: [Span { start: 138603, end: 138609 }], parts: [Span { start: 138612, end: 138618 }] })
]
}
]
}
```
Which should contains only one `LitePipeline`, and the second
`LitePipeline` is generated because of `Eol` lex token:
```
[
Token { contents: Item, span: Span { start: 138600, end: 138602 } },
Token { contents: Eol, span: Span { start: 138602, end: 138603 } }, // it generates the second LitePipeline
Token { contents: Comment, span: Span { start: 138603, end: 138609 } },
Token { contents: Pipe, span: Span { start: 138610, end: 138611 } },
Token { contents: Item, span: Span { start: 138612, end: 138618 } }
]
```
To fix the issue, I remove the `Eol` token when we meet `Comment` right
after `Eol`, then it will generate a good LiteBlock, and everything will
work fine.
### After the fix:
Token:
```
[
Token { contents: Item, span: Span { start: 138618, end: 138620 } },
Token { contents: Comment, span: Span { start: 138622, end: 138628 } },
Token { contents: Pipe, span: Span { start: 138629, end: 138630 } },
Token { contents: Item, span: Span { start: 138631, end: 138637 } }
]
```
LiteBlock:
```
LiteBlock {
block: [
LitePipeline {
commands: [
Command(
None,
LiteCommand {
comments: [Span { start: 138622, end: 138628 }],
parts: [Span { start: 138618, end: 138620 }]
}
),
Command(
Some(Span { start: 138629, end: 138630 }),
LiteCommand { comments: [], parts: [Span { start: 138631, end: 138637 }] })] }] }
```
<!--
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.
-->
# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.
Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
this PR makes nushell use mimalloc as the default allocator, this has
the benefit of reducing startup time on my machine. `17%` on linux and
`22%` on windows, when testing using hyperfine.
the overhead to compile seem to be quite small, aswell as the increase
of binary size quite small
on linux the binary went from `33.1mb` to `33.2mb`
linux
![image](https://github.com/nushell/nushell/assets/17986183/ba5379b4-2c08-483a-a9ff-a9d8524d2943)
windows
![image](https://github.com/nushell/nushell/assets/17986183/fda5090f-96a9-48d1-ada4-617694b9d880)
# 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.
-->
# 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)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx
you can also mention related issues, PRs or discussions!
-->
# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.
Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
This PR removes ZB and ZiB from file size type, as they
were showing incorrect values due to an integer overflow.
Fixes: #9337
# 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.
-->
# Description
This PR updates the ini dependency.
# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.
Make sure you've run and fixed any issues with these commands:
- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -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.
-->
# Description
Update the polars dependency for dataframes to stay on-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.
-->
# Description
I'm not sure if this is a good idea or now but I did it to fix#9418. It
allows you to pass empty string arguments like this.
file named foo.nu
```
def main [--arg: string = dog] {
if ($arg | is-empty) {
echo "empty string"
} else {
echo $arg
}
}
```
`> nu foo.nu --arg ""`
or
`> nu foo.nu --arg=""`
this gives an error
`> nu foo.nu --arg`
this returns the default argument
`> nu foo.nu`
closes#9418
# 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.
-->
# Description
This PR is trying to allow you to have `[blah]` in your path and yet
still have `ls` work. This is done by trying to separate the path from
the pattern to be searched for. It may still need more work.
I've tested it with:
- mkdir "[test]"
- cd "[test]"
- ls
Related to #9307
Hopefully fixes#9232
# 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.
-->
close#9335
I am not sure whether the fix was better to be delived as a minor bump
but it is what is is.
Could you @fdncred test it somehow?
I did it by checking out back the the original commit before the PR
refered in the issue.
---------
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
# 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
(-)
Just makes it easier to find these commands when using the `help` system
- the `find` command already has the "regex" search term.
Co-authored-by: ja_cop <ja_cop@hoshi>
# 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.
-->
Trying to fix#9394.
The problem with PR #9159 seems to be when searching for multiple terms,
each term is checked against the original values. It outputs a new value
for each such check, thus introducing replication for each search term.
As a result, it works fine with num of search term = 1.
# Description
Test runner now performs following actions in order to run tests:
* Module file is opened
* Public function with random name is added to the source code, this
function calls user-specified private function
* Modified module file is saved under random name in $nu.temp-path
* Modified module file is imported in subprocess, injected function is
called by the test runner
# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
* Test functions no longer need to be exported
* test functions no longer need to reside in separate test_ files
* setup and teardown renamed to before-each and after-each respectively
* before-all and after-all functions added that run before all tests in
given module. This matches the behavior of test runners used by other
languages such as JUnit/TestNG or Mocha
# Tests + Formatting
# After Submitting
---------
Co-authored-by: Kamil <skelly37@protonmail.com>
Co-authored-by: amtoine <stevan.antoine@gmail.com>