# Description
Add float, string, and date patterns to matcher.
This could probably use some tests 😅
# 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.
# Description
This moves the representation of variables on the stack to a Vec, which
more closely resembles a stack. For small numbers of variables live at
any one point, this tends to be more efficient than a HashMap. Having a
stack-like vector also allows us to remember a stack position,
temporarily push variables on, then quickly drop the stack back to the
original size when we're done. We'll need this capability to allow
matching inside of conditions.
On this mac, a simple run of:
`timeit { mut x = 1; while $x < 1000000 { $x += 1 } }`
Went from 1 sec 86 ms, down to 1 sec 2 ms. Clearly, we have a lot more
ground we can make up in looping speed 😅 but it's nice that for fixing
this to make matching easier, we also get a win in terms of lookup speed
for small numbers of variables.
# User-Facing Changes
Likely users won't (hopefully) see any negative impact and may even see
a small positive 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` 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.
# Description
@fdncred noticed an
[issue](https://github.com/nushell/nushell/pull/8529#issuecomment-1482770636)
with list annotations that while i was trying to find a fix found
another issue.
innitially, this was accepted by the parser
```nu
def err [list: list<int> = ['a' 'b' 'c']] {}
```
but now an error is raised
```nu
Error: nu::parser::assignment_mismatch
× Default value wrong type
╭─[entry #1:1:1]
1 │ def err [list: list<int> = ['a' 'b' 'c']] {}
· ──────┬────
· ╰── expected default value to be `list<int>`
╰────
```
# User-Facing Changes
none
# Tests + Formatting
done
this pr refines #8270 and closes#8109
# description
examples:
the original syntax is okay
```nu
def okay [nums: list] {} # the type of list will be list<any>
```
empty annotations are allowed in any variation
the last two may be caught by a future formatter,
but do not affect `nu` code currently
```nu
def okay [nums: list<>] {} # okay
def okay [nums: list< >] {} # weird but also okay
def okay [nums: list<
>] {} # also weird but okay
```
types are allowed (See [notes](#notes) below)
```nu
def okay [nums: list<int>] {} # `test [a b c]` will throw an error
def okay [nums: list< int > {} # any amount of space within the angle brackets is okay
def err [nums: list <int>] {} # this is not okay, `nums` and `<int>` will be parsed as
# two separate params,
```
nested annotations are allowed in many variations
```nu
def okay [items: list<list<int>>] {}
def okay [items: list<list>] {}
```
any unterminated annotation is caught
```nu
Error: nu::parser::unexpected_eof
× Unexpected end of code.
╭─[source:1:1]
1 │ def err [nums: list<int] {}
· ▲
· ╰── expected closing >
╰────
```
unknown types are flagged
```nu
Error: nu::parser::unknown_type
× Unknown type.
╭─[source:1:1]
1 │ def err [nums: list<str>] {}
· ─┬─
· ╰── unknown type
╰────
Error: nu::parser::unknown_type
× Unknown type.
╭─[source:1:1]
1 │ def err [nums: list<int, string>] {}
· ─────┬─────
· ╰── unknown type
╰────
```
# notes
the error message for mismatched types in not as intuitive
```nu
Error: nu::parser::parse_mismatch
× Parse mismatch during operation.
╭─[source:1:1]
1 │ def err [nums: list<int>] {}; err [a b c]
· ┬
· ╰── expected int
╰────
```
it should be something like this
```nu
Error: nu::parser::parse_mismatch
× Parse mismatch during operation.
╭─[source:1:1]
1 │ def err [nums: list<int>] {}; err [a b c]
· ──┬──
· ╰── expected list<int>
╰────
```
this is currently not implemented
# Description
I need a command that will transform hex string into bytes and into
other direction.
I've implemented `decode hex` command and `encode hex` command. (Based
on `encode base64` and `decode base64` commands
# User-Facing Changes
```
> '010203' | decode hex
0x[01 02 03]
```
and
```
> 0x[01 02 0a] | encode hex
'01020A'
```
---------
Co-authored-by: whiteand <andrewbeletskiy@gmail.com>
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 "... in application
code" (<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>
# Description
Fix patterns in pattern matching to properly declare their variables
when discovering which variables need to be closed over when creating a
closure.
Also, moves `collect` to core, so that the core language can use `$in`.
Fixes#8595
# 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.
# Description
Allows `timeit` to also run commands directly, eg) `timeit ls -la`
# User-Facing Changes
Additional capabilities to `timeit`.
# 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.
# Description
This does a couple random changes/fixes:
* Moves `timeit` to use a block instead of a closure. This makes it a
bit more flexible.
* Moves var bindings in patterns to be immutable
# User-Facing Changes
`timeit` now takes a block and no arguments.
# 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.
# 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.
# Description
This PR just tweaks the std.nu logging a bit. It looks like this after
this PR. I like the ability to have a parse-able file, which is why
there are pipes, and I like to have a pretty granular time date stamp in
order to get rough performance metrics.
```
nu crates\nu-utils\standard_library\tests.nu
INF|2023-03-23T15:02:00.284|Run test test_asserts test_assert
INF|2023-03-23T15:02:00.372|Run test test_asserts test_assert_equal
INF|2023-03-23T15:02:00.461|Run test test_asserts test_assert_error
INF|2023-03-23T15:02:00.585|Run test test_asserts test_assert_greater
INF|2023-03-23T15:02:00.674|Run test test_asserts test_assert_greater_or_equal
INF|2023-03-23T15:02:00.762|Run test test_asserts test_assert_length
INF|2023-03-23T15:02:00.847|Run test test_asserts test_assert_less
INF|2023-03-23T15:02:00.933|Run test test_asserts test_assert_less_or_equal
INF|2023-03-23T15:02:01.021|Run test test_asserts test_assert_not_equal
INF|2023-03-23T15:02:01.110|Run test test_dirs test_dirs_command
INF|2023-03-23T15:02:01.300|Run test test_logger test_critical
INF|2023-03-23T15:02:01.558|Run test test_logger test_debug
INF|2023-03-23T15:02:01.818|Run test test_logger test_error
INF|2023-03-23T15:02:02.074|Run test test_logger test_info
INF|2023-03-23T15:02:02.331|Run test test_logger test_warning
INF|2023-03-23T15:02:02.573|Run test test_std test_match
INF|2023-03-23T15:02:02.678|Run test test_std test_path_add
```
# 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.
# Description
This PR changes some help text to try and clarify how `register` works
when using from `nu -c`.
# 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.
# Description
This PR is to make test_dirs.nu work better on macos.
closes#8528
# 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.
# 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.
# Description
## Symptom
Lines which are input into `from ssv --aligned-columns` are split
incorrectly of they contain utf-8 characters which have the length of
multiple bytes. Notice how the values of the `Bars` column bleeds into
the `Security` column in the following output (the big grey areas are
censored data ;) ):
![before-patch](https://user-images.githubusercontent.com/17351844/226757737-be7ca493-5c64-4a91-9153-984df515bb8c.png)
## Problem
The function behind `from ssv --aligned-columns` splits lines into
fields by byte index (which is default behavior of str.get(...) in Rust)
instead of character index. If the header row has a different length in
bytes than the remaining table rows, the split is executed incorrectly.
## Solution
The function behind `from ssv --aligned-columns1 now separates lines by
character index instead of byte index. This productes the following
(correct) output (the big grey areas are censored data ;) ):
![after-patch](https://user-images.githubusercontent.com/17351844/226757850-7acaebf3-2d40-4f85-b76e-64e465254bda.png)
This is a follow-up to https://github.com/nushell/nushell/pull/8379 and
https://github.com/nushell/nushell/discussions/8502.
This PR makes it so that the new `?` syntax for marking a path member as
optional short-circuits, as voted on in the
[8502](https://github.com/nushell/nushell/discussions/8502) poll.
Previously, `{ foo: 123 }.bar?.baz` would raise an error:
```
> { foo: 123 }.bar?.baz
× Data cannot be accessed with a cell path
╭─[entry #15:1:1]
1 │ { foo: 123 }.bar?.baz
· ─┬─
· ╰── nothing doesn't support cell paths
╰────
```
Here's what was happening:
1. The `bar?` path member access returns `nothing` because there is no field named `bar` on the record
2. The `baz` path member access fails when trying to access a `baz` field on that `nothing` value
After this change, `{ foo: 123 }.bar?.baz` returns `nothing`; the failed `bar?` access immediately returns `nothing` and the `baz` access never runs.
# Description
This is an experiment to see what switching the `let/let-env` family to
math expressions for initialisers would be like.
# User-Facing Changes
This would require any commands you call from `let x = <command here>`
(and similar family) to call the command in parentheses. `let x = (foo)`
to call `foo`.
# 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.
I was looking where we could remove the usage of once-cell dependency.
As for now, I only found one place. Not a terrible improvement, but at
least, it removes a dependency nu-test-support crate.
Relies on `Mutex::new` constified in Rust 1.63.0
# Description
this PR
- refactors `ErrorMake::run` to avoid duplicate branches depending on
the value of `--unspanned`
- completes the examples
1. show a really simple `error make` call, without any command
definition
2. show a complete error format with all possible fields
3. the command definition but with indentation and slightly better
description
- adds results to the first two examples
- gives meaningful error messages for all known "bad" error formats,
using the span of the error format or the span of `$format.label` to
better explain why the format is bad
# User-Facing Changes
users have now the following help
```bash
Examples:
Create a simple custom error
> error make {msg: "my custom error message"}
Create a more complex custom error
> error make {
msg: "my custom error message"
label: {
text: "my custom label text" # not mandatory unless $.label exists
start: 123 # not mandatory unless $.label.end is set
end: 456 # not mandatory unless $.label.start is set
}
}
Create a custom error for a custom command that shows the span of the argument
> def foo [x] {
let span = (metadata $x).span;
error make {
msg: "this is fishy"
label: {
text: "fish right here"
start: $span.start
end: $span.end
}
}
}
```
and the following error messages when the error format is bad
https://asciinema.org/a/568107🥳
# Tests + Formatting
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🔴 `cargo test --workspace`
=> the tests do not pass but they do not pass on latest `main` either =>
i should `cargo clean`, but that's an expensive operation on my
machine...
# After Submitting
the documentation would have to be regenerated over on the website
# Description
Fixes: #8548
# User-Facing Changes
```
❯ register target/debug/formats
Error:
× Register plugin failed
╭─[entry #1:1:1]
1 │ register target/debug/formats
· ──────────┬─────────
· ╰── plugin name must starts with nu_plugin_
╰────
```
# 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.
…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.
Should close#7255.
# Description
**TL;DR**: this PR adds `--indent <int>`, `--tabs <int>` and `--raw` to
control a bit more the `string` output of `to nuon`, as done in `to
json` already, the goal being to promote the `NUON` format through easy
to read and formatted output `.nuon` files 😋
### outside of `crates/nu-command/src/formats/to/nuon.rs`
as the signature of `value_to_string` has changed, the single call to it
outside of its module definition has been changed to use default values
=> `value_to_string(&value, Span::unknown(), 0, &None)` in
`crates/nu-command/src/filters/uniq.rs`
### changes to `ToNuon` in `crates/nu-command/src/formats/to/nuon.rs`
- the signature now features `--raw`, `--indent <int>` and `--tabs
<int>`
- the structure of the `run` method is inspired from the one in `to
json`
- we get the values of the arguments
- we convert the input to a usable `Value`
- depending on whether the user raised `--raw`, `--indent` or `--tabs`,
we call the conversion to `string` with different values of the
indentation, starting at depth 0
- finally, we return `Ok` or a `ShellError::CantConvert` depending on
the conversion result
- some tool functions
- `get_true_indentation` gives the full indentation => `indent` repeated
`depth` times
- `get_true_separators` gives the line and field separators => a `("\n",
"")` when using some formatting or `("", " ")` when converting as pure
string on a single line
the meat of `nuon.rs` is now the `value_to_string` recursive function:
- takes the depth and the indent string
- adds correct newlines, space separators and indentation to the output
- calls itself with the same indent string but `depth + 1` to increase
the indentation by one level
- i used the `nl`, `idt`, `idt_po` (**i**n**d**en**t** **p**lus **o**ne)
and `idt_pt` (**i**n**d**en**t** **p**lus **t**wo) to make the
`format!`s easier to read
# User-Facing Changes
users can now
- control the amount and nature of NUON string output indentation with
- `--indent <number of " " per level>`
- `--tabs <number of "\t" per level>`
- use the previous behaviour of `to nuon` with the `--raw` option
- have new examples with `help to nuon`
> **Note**
> the priority order of the options is the following
> 1. `--raw`
> 2. `--tabs`
> 3. `--indent`
>
> the default is `--indent 2`
# Tests + Formatting
### new tests
- tests involving the string output of `to nuon`, i.e. tests not of the
form `... | to nuon | from nuon ...`, now use the `to nuon --raw`
command => this is the smallest change to have the tests pass, as the
new `to nuon --raw` is equivalent to the old `to nuon`
- in `crates/nu-command/src/formats/to/nuon.rs`, the previous example
has been replaced with three examples
- `[1 2 3] | to nuon` to show the default behaviour
- `[1 2 3] | to nuon --raw` to show the not-formatted output
- a more complex example with `{date: 2000-01-01, data: [1 [2 3] 4.56]}
| to nuon`
- the result values have been defined and the `examples` tests pass
### dev
- 🟢 `cargo fmt --all`
- 🟢 `cargo clippy --workspace -- -D warnings -D
clippy::unwrap_used -A clippy::needless_collect`
- 🟢 `cargo test --workspace` ~~passes but without
`to_nuon_errs_on_closure`~~ fixed in
0b4fad7eff
# After Submitting
the `to nuon` page would have to be regenerated at some point due to the
new tests
# Description
Fixes#6706.
I took a look at this issue and it seems that the issue is because the
path is canonicalized and thus derives to the target. I've tested it
locally by checking if the path is a symlink and acting accordingly to
not canonicalize it and it seems fine.
In current release if the target is deleted but the symlink remains and
one `ls`'s it, it throws a `directory not found` error. But with the fix
it still shows the symlink (with red background, indicating missing
target).
The change I've applied only triggers when `ls` is done on a symlink, on
all other counts it should basically do the same as before.
# 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
## List existing symlink and target
Current
```
ls a_symlink ╭───┬────────┬──────┬──────┬──────────────╮
│ # │ name │ type │ size │ modified │
├───┼────────┼──────┼──────┼──────────────┤
│ 0 │ a_file │ file │ 0 B │ 20 hours ago │
╰───┴────────┴──────┴──────┴──────────────╯
```
With fix
```
ls a_symlink ╭───┬───────────┬─────────┬──────┬──────────────╮
│ # │ name │ type │ size │ modified │
├───┼───────────┼─────────┼──────┼──────────────┤
│ 0 │ a_symlink │ symlink │ 6 B │ 20 hours ago │
╰───┴───────────┴─────────┴──────┴──────────────╯
```
## List existing symlink with missing target
Current
```
ls symfile_x
Error: nu:🐚:directory_not_found (link)
× Directory not found
╭─[entry #13:1:1]
1 │ ls symfile_x
· ────┬────
· ╰── directory not found
╰────
```
With fix
```
ls symfile_x ╭───┬───────────┬─────────┬──────┬─────────────╮
│ # │ name │ type │ size │ modified │
├───┼───────────┼─────────┼──────┼─────────────┤
│ 0 │ symfile_x │ symlink │ 6 B │ 2 hours ago │
╰───┴───────────┴─────────┴──────┴─────────────╯
```
# Description
Unbreak unit tests by updating default config for the new hook that
landed after the syntax change but didn't get its tests re-run.
# 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.
# Description
as we now want to put all the library in `std.nu` alone, this PR removes
the mentions to "creating a separate submodule from `std.nu`" from the
`README` of the standard library and adds a few clarifications about the
structure of the library.
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
```
$nothing
```
# After Submitting
```
$nothing
```
# 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.
when running the tests inside nu-protocol we were getting a compiler
warning...
this PR removes the compiler warning from nu-protocol.
by adding
```rust
#[allow(unused_imports)]
```
# Description
## in the `test_dirs` test module
- use the `std assert` function in the `test_dirs` module instead of
`myassert`
- refactor the "test cleaning" in the `clean` command
- allows to clean the tests and then throw a real error in the `catch`
block in case there is an error
- the test still "try"s to `clean` the test directory after the `catch`,
like in a "finally" block
- parse the `catch` error and `error make` a proper one instead of
`debug`ging it => because the `catch` will be triggered as soon as one
error occurs, there will always only be a single error in the tests, so
this does not change the behaviour of failing `dirs` tests!
> **Note**
> i'm not particularly happy with the parsing stage in the `catch`
block.
> however that's the simplest i found to both keep the `try` / `catch`
construct that allows to clean the test directory and have a proper
error at the same time!
## in the global `tests` module
- use `print` instead of `echo` to make sure the log statements show up
during the tests
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
```bash
nu crates/nu-utils/standard_library/tests.nu
```
passes but now with
- proper log statements
- proper error when a `dirs` error occurs => try with `sd 'assert \(1'
"assert (10" crates/nu-utils/standard_library/test_dirs.nu` 😉
# After Submitting
```
$nothing
```
# Description
```nushell
log critical "this is a critical message"
log error "this is an error message"
log warning "this is a warning message"
log info "this is an info message"
log debug "this is a debug message"
```
![image](https://user-images.githubusercontent.com/282320/225071852-1ddf0e87-d12b-452d-9598-5122df7123ab.png)
# Tests + Formatting
Tests are written. To run automatically, #8443 needs to be merged before
or after this PR.
---------
Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
# Description
as closures now need to have explicit parameters, this PR adds the empty
`||` to the two closure of the `std match` test.
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
```
nu crates/nu-utils/standard_library/tests.nu
```
does not give the following anymore
```
Error: nu::parser::closure_missing_pipe
× Missing || inside closure
╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/test_std.nu:29:1]
29 │ let branches = {
30 │ 1: { -1 }
· ───┬──
· ╰── Parsing as a closure, but || is missing
31 │ 2: { -2 }
╰────
help: Try add || to the beginning of closure
Error: nu:🐚:only_supports_this_input_type
× Input type not supported.
╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:7:1]
7 │ nu -c $'use ($test_file) *; $nu.scope.commands | to nuon'
8 │ | from nuon
· ────┬────
· ╰── input type: nothing
9 │ | where module_name == $module_name
· ──┬──
· ╰── only list, binary, raw data or range input data is supported
10 │ | where ($it.name | str starts-with "test_")
╰────
```
# After Submitting
```
$nothing
```
# Description
This adds two different features to `open`:
* The ability to pass more than one file to `open`.
* Support for using globs in the filenames
`open` will create a list stream and stream the output if there is more
than one file opened
Examples:
```
open file1.csv file2.csv file3.csv
```
```
open *.nu | where $it =~ "echo"
```
# User-Facing Changes
Multi-file and glob support in `open`. Original `open` functionality
should continue as before.
# 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.
> **Warning**
> this PR is the result of a demand from the core team, to have the
simplest structure for the standard library, at least for now 👍
# Description
this PR mainly
- moved the `dirs.nu` module to the end of `std.nu`
- fixed the imports in `test_dirs.nu`
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
with the new runner from #8443, we get as expected 👌
```
>_ nu crates/nu-utils/standard_library/tests.nu
INFO Run tests in test_dirs
DEBUG Run test test_dirs/test_dirs_command
INFO Run tests in test_std
DEBUG Run test test_std/test_assert
DEBUG Run test test_std/test_match
DEBUG Run test test_std/test_path_add
```
# After Submitting
```
$nothing
```