# Description
i was playing with my theme a bit and i was thinking about the following
- the default themes should not use precise colors
- the default themes should let the terminal set the exact colors
for instance, the `filesize` field of the `$env.config.color_config`
looks good but not with terminal themes like dracula or tokyonight
😮
in this PR, i just use "built-in" colors, like `red` or `yellow_bold` or
`{fg: green attr: n}` to let the terminal theme set the colors 😋
# User-Facing Changes
i tried to stay as close as the previous default themes, so there should
be the least amount of differences 😌
# Tests + Formatting
```
$nothing
```
# After Submitting
```
$nothing
```
# 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.
# Description
as we now have a prelude thanks to #8627, i'd like to work on the
structure of the library 😋
and i think the first step is to make it a true standalone crate 😏
this PR
- moves all the library from `crates/nu-utils/standard_library/` to
`crates/nu-std/`
- moves the `rust` loading code from `src/run.rs` to
`crates/nu-std/src/lib.rs`
# 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>
# Description
Add `xaccess`,`xupdate` and `xinsert` scripts to standard library. They
allow accessing and manipulating data in new xml format
https://github.com/nushell/nushell/pull/7947 with relative ease.
Access some data in nushell xml structure:
![image](https://user-images.githubusercontent.com/17511668/224785447-317359e2-1430-4dfc-9307-73f1d5e50098.png)
Update attributes of xml tags matching a path:
![image](https://user-images.githubusercontent.com/17511668/224785506-85e9aa30-b36b-43db-af1d-2f4460563124.png)
# User-Facing Changes
New commands `std xaccess`, `std xupdate` and `std xinsert`
# 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 the associated poin in #8311
# Description
this PR adds a `clip` command to `std` which
- has error support in case the clipboard system command is not
installed
- removes any ANSI escape sequences from the input to have a clean
copied text
- can throw desktop notifications on linux in case of a long pipeline
which needs to be copied (can be disabled with `--no-notify`)
- echoes the copied data to the output of the terminal (can be disabled
with --silent)
- has examples and dependencies listed
- has "charpage" 65001 (a.k.a. utf-8) support for windows
## new additions from 9cd3c951f to
ad3e8de25b
- better OS context error support
- use of the `match` statement for scalability
- `match` the value of the `$nu.os-info.name`
- add `macOS` with `pbcopy` to the list of supported systems
- throw an error when the OS is not supported
- ~~add simple tests to make sure `clip` works on all main OSes with the
CI~~ had to be removed in 6028b98483 (see
[the failing
test](https://github.com/nushell/nushell/actions/runs/4610091544/jobs/8148126550?pr=8695#step:6:35))
# User-Facing Changes
users can now access a `clip` to copy the output of any pipeline to the
system clipboard, on any system
# Tests + Formatting
```
$nothing
```
# After Submitting
```
$nothing
```
# Description
fixed#8655
Change default nushell configuration file `default_env.nu` to display
LAST_EXIT_CODE in the prompt. For this change, users can quickly know
that a previous command failed.
# User-Facing Changes
This change affects only users who use the default configuration.
When a command fails, the exit code is displayed in the prompt like
these figures.
* before
![image](https://user-images.githubusercontent.com/37319612/229782830-45bc6b0d-75e4-459f-ae1d-46877f740239.png)
* after
![image](https://user-images.githubusercontent.com/37319612/229784089-e68b5d14-499b-4448-b764-e6b30ca64714.png)
# Tests + Formatting
When I ran tests, `test.nu` failed with the following error.
The error also occurs in the master branch, so it's probably unrelated
to these changes.
Do I need to address it?
* `cargo fmt --all -- --check`: passed
* `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect`: passed
* `cargo test --workspace`: passed
* `cargo run -- crates/nu-utils/standard_library/tests.nu`: ~failed~
passed
```
~/oss_dev/nushell> cargo run -- crates/nu-utils/standard_library/tests.nu
Finished dev [unoptimized + debuginfo] target(s) in 0.15s
Running `target/debug/nu crates/nu-utils/standard_library/tests.nu`
Error: nu:🐚:external_command
× External command failed
╭─[/home/hiroki/oss_dev/nushell/crates/nu-utils/standard_library/tests.nu:73:1]
73 │ | upsert test {|module|
74 │ nu -c $'use ($module.file) *; $nu.scope.commands | select name module_name | to nuon'
· ─┬
· ╰── did you mean 'du'?
75 │ | from nuon
╰────
help: No such file or directory (os error 2)
```
# After Submitting
nothing
# 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
Should close https://github.com/nushell/nushell/issues/8698 and similar
issues.
# Description
simply moves the `show_banner` field and its comment to the top of the
default config file.
# User-Facing Changes
this should make the setting easier to see and encourage people to
modify the line instead of adding another line before the default
`show_banner: true`, which would overwrite the setting.
# Tests + Formatting
```
$nothing
```
# After Submitting
the default banner links to
https://www.nushell.sh/book/configuration.html#remove-welcome-message,
which does not mention this issue => this will have to be updated
Related to #8653.
# Description
This PR removes the redundant `path expand`s introduced in #8552 and
#8576.
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
the tests still pass on linux.
# After Submitting
```
$nothing
```
Related to #8150, #8635 and #8632.
# Description
i've introduced a bad set of tests for the `assert equal` command in
#8150...
they should not compare `1 + 2` and `4)` or `3)` but the ints.
in this PR, i remove this spurious parentheses that were not planned at
all 😬👀
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
```
>_ nu crates/nu-utils/standard_library/tests.nu
INF|2023-03-28T20:18:13.022|Running tests in test_asserts
INF|2023-03-28T20:18:13.173|Running tests in test_dirs
INF|2023-03-28T20:18:13.247|Running tests in test_logger
INF|2023-03-28T20:18:13.473|Running tests in test_std
```
# After Submitting
```
$nothing
```
# Description
Require that any value that looks like it might be a number (starts with
a digit, or a '-' + digit, or a '+' + digits, or a special form float
like `-inf`, `inf`, or `NaN`) must now be treated as a number-like
value. Number-like syntax can only parse into number-like values.
Number-like values include: durations, ints, floats, ranges, filesizes,
binary data, etc.
# User-Facing Changes
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
BREAKING CHANGE
Just making sure we see this for release notes 😅
This breaks any and all numberlike values that were treated as strings
before. Example, we used to allow `3,` as a bare word. Anything like
this would now require quotes or backticks to be treated as a string or
bare word, respectively.
# 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.
the first part of this PR comes from a request from @presidento in
#8525.
the second one is an improvement of the error support.
# Description
this PR
- computes `module_search_pattern` to only `ls` the selected modules =>
the goal is to save search time in the future with more tests
- gives better errors when
- the `--path` is invalid
- the `--module` does not exist
- the search is too strict
### examples
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --path does-not-exist
Error:
× directory_not_found
╭─[<commandline>:1:1]
1 │ main --path does-not-exist
· ───────┬──────
· ╰── no such directory
╰────
```
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --module does-not-exist
Error:
× module_not_found
╭─[<commandline>:1:1]
1 │ main --module does-not-exist
· ───────┬──────
· ╰── no such module in /home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/
╰────
```
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --command does_not_exist
Error:
× no test to run
```
instead of the previous
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --path does-not-exist
Error:
× No matches found for /home/amtoine/.local/share/git/store/github.com/amtoine/nushell/does-not-exist/test_*.nu
╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:32:1]
32 │ let tests = (
33 │ ls ($path | default $env.FILE_PWD | path join "test_*.nu")
· ───────────────────────────┬───────────────────────────
· ╰── Pattern, file or folder not found
34 │ | each {|row| {file: $row.name name: ($row.name | path parse | get stem)}}
╰────
help: no matches found
```
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --module does-not-exist
Error:
× expected table from pipeline
╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:59:1]
59 │ $tests_to_run
60 │ | group-by module
· ────┬───
· ╰── requires a table input
61 │ | transpose name tests
╰────
```
```bash
>_ nu crates/nu-utils/standard_library/tests.nu --command does-not-exist
Error:
× expected table from pipeline
╭─[/home/amtoine/.local/share/git/store/github.com/amtoine/nushell/crates/nu-utils/standard_library/tests.nu:59:1]
59 │ $tests_to_run
60 │ | group-by module
· ────┬───
· ╰── requires a table input
61 │ | transpose name tests
╰────
```
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
```
$nothing
```
# After Submitting
```
$nothing
```
Should close#8616.
Related to #8590.
# Description
With the new builtin `match` command introduced in the `rust` source in
#8590, there is no need to have a custom `match` in the standard
library.
This PR removes the `match` command from `std.nu` and the associated
test.
# User-Facing Changes
Users can not access `match` from `std.nu`.
# Tests + Formatting
```
nu crates/nu-utils/standard_library/tests.nu --path crates/nu-utils/standard_library/ out+err> /dev/null; ($env.LAST_EXIT_CODE == 0)
```
gives `true`
# After Submitting
```
$nothing
```
Should close one of the tasks in #8450.
# Description
> **Note**
> in order of appearance in the global diff
- 1b7497c419 adds the `std-tests` job to
the CI which
1. installs `nushell` in the runner
2. run the `tests.nu` module
> see `open .github/workflows/ci.yml | get jobs.std-tests | to yaml`
-
[`ec85b6fd`..`9c122115`](ec85b6fd3fc004cd94e3fada5c8e5fe2714fd629..9c12211564ca8ee90ed65ae45776dccb8f8e4ef1)
is where all the magic happens => see below
- 🧪799c7eb7fd introduces some
bugs and failing test to see how the CI behaves => see how the [tests
failed](https://github.com/nushell/nushell/actions/runs/4460098237/jobs/7833018256)
as expected ❌
- 🧪 and c3de1fafb5 reverts the
failing tests, i.e. the previous commit, leaving a standard library
whose tests all pass 🎉 => see the [tests
passing](https://github.com/nushell/nushell/actions/runs/4460153434/jobs/7833110719?pr=8525#step:5:1)
now ✔️
## the changes to the runner
> see
[`ec85b6fd`..`9c122115`](ec85b6fd3fc004cd94e3fada5c8e5fe2714fd629..9c12211564ca8ee90ed65ae45776dccb8f8e4ef1)
the issue with the previous runner was the following: the clever trick
of using `nu -c "use ...; test"` did print the errors when occuring but
they did not capture the true "failure", i.e. in all cases the
`$env.LAST_EXIT_CODE` was set to `0`, never stopping the CI when a test
failed 🤔
i first tried to `try` / `catch` the error in
ec85b6fd3f which kinda worked but only
throw a single error, the first one
i thought it was not the best and started thinking about a solution to
have a complete report of all failing tests, at once, to avoid running
the CI multiple times!
the easiest solution i found was the one i implemented in
9c12211564
> **Warning**
> this changes the structure of the runner quite a bit, but the `for`
loops where annoying to manipulate structured data and allow the runner
to draw a complete report...
now the runner does the following
- compute the list of all available tests in a table with the `file`,
`module` and `name` columns (first part of the pipe until `flatten` and
`rename`)
- run the tests one by one computing the new `pass` column
- with a `log info`
- captures the failing ones => puts `true` in `pass` if the test passes,
`false` otherwise
- if at least one test has failed, throw a single error with the list of
failing tests
### hope you'll like it 😌
# User-Facing Changes
```
$nothing
```
# Tests + Formatting
the standard tests now return a true error that will stop the CI
# After Submitting
```
$nothing
```
# 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 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
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.
# 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
```
> **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
```
# Description
As title, closes: #7921closes: #8273
# User-Facing Changes
when define a closure without pipe, nushell will raise error for now:
```
❯ let x = {ss ss}
Error: nu::parser::closure_missing_pipe
× Missing || inside closure
╭─[entry #2:1:1]
1 │ let x = {ss ss}
· ───┬───
· ╰── Parsing as a closure, but || is missing
╰────
help: Try add || to the beginning of closure
```
`any`, `each`, `all`, `where` command accepts closure, it forces user
input closure like `{||`, or parse error will returned.
```
❯ {major:2, minor:1, patch:4} | values | each { into string }
Error: nu::parser::closure_missing_pipe
× Missing || inside closure
╭─[entry #4:1:1]
1 │ {major:2, minor:1, patch:4} | values | each { into string }
· ───────┬───────
· ╰── Parsing as a closure, but || is missing
╰────
help: Try add || to the beginning of closure
```
`with-env`, `do`, `def`, `try` are special, they still remain the same,
although it says that it accepts a closure, but they don't need to be
written like `{||`, it's more likely a block but can capture variable
outside of scope:
```
❯ def test [input] { echo [0 1 2] | do { do { echo $input } } }; test aaa
aaa
```
Just realize that It's a big breaking change, we need to update config
and scripts...
# 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.
# 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.
# Description
This PR tweaks the enable_vt_processing() function with more verbose
error handling. This is related to #8344.
# 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.
# Description
Was original asked here:
https://github.com/nushell/nushell/pull/8405#issuecomment-1465062652
Make it easier to extend standard library with submodules.
(For a new submodule called `xx.nu` the tests can be written in
`test_xx.nu`).
Test discovery is implemented.
# User-Facing Changes
There are no user-facing changes.
# Tests + Formatting
Tests are updated.
There is no `nufmt` now.
---------
Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
Should close#8444.
# Description
as asked by @presidento, i've used a generic command to run the tests.
i've also transformed the "a concrete example" sections into quote
blocks to make them stand out less.
not sure about that one, please tell me what you think 😋
i think a small example is always helpfull, maybe some work has to be
done to make it better 💪
# User-Facing Changes
hopefully a slightly clearer README for the standard library
# Tests + Formatting
```
$nothing
```
# After Submitting
```
$nothing
```
It is a common pattern to add message to assert.
Also the error message was not so helpful. (See the difference in the
documentation)
---------
Co-authored-by: Mate Farkas <Mate.Farkas@oneidentity.com>
# Description
Prototype replacement for `enter`, `n`, `p`, `exit` built-ins
implemented as scripts in standard library.
MVP-level capabilities (rough hack), for feedback please. Not intended
to merge and ship as is.
_(Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.)_
# User-Facing Changes
New command in standard library
```nushell
〉use ~/src/rust/nushell/crates/nu-utils/standard_library/dirs.nu
---------------------------------------------- /home/bobhy ----------------------------------------------
〉help dirs
module dirs.nu -- maintain list of remembered directories + navigate them
todo:
* expand relative to absolute paths (or relative to some prefix?)
* what if user does `cd` by hand?
Module: dirs
Exported commands:
add (dirs add), drop, next (dirs next), prev (dirs prev), show (dirs show)
This module exports environment.
---------------------------------------------- /home/bobhy ----------------------------------------------
〉dirs add ~/src/rust/nushell /etc ~/.cargo
-------------------------------------- /home/bobhy/src/rust/nushell --------------------------------------
〉dirs next 2
------------------------------------------- /home/bobhy/.cargo -------------------------------------------
〉dirs show
╭───┬─────────┬────────────────────╮
│ # │ current │ path │
├───┼─────────┼────────────────────┤
│ 0 │ │ /home/bobhy │
│ 1 │ │ ~/src/rust/nushell │
│ 2 │ │ /etc │
│ 3 │ ==> │ ~/.cargo │
╰───┴─────────┴────────────────────╯
------------------------------------------- /home/bobhy/.cargo -------------------------------------------
〉dirs drop
---------------------------------------------- /home/bobhy ----------------------------------------------
〉dirs show
╭───┬─────────┬────────────────────╮
│ # │ current │ path │
├───┼─────────┼────────────────────┤
│ 0 │ ==> │ /home/bobhy │
│ 1 │ │ ~/src/rust/nushell │
│ 2 │ │ /etc │
╰───┴─────────┴────────────────────╯
---------------------------------------------- /home/bobhy ----------------------------------------------
〉
```
# Tests + Formatting
Haven't even looked at stdlib `tests.nu` yet.
Other todos:
* address module todos.
* integrate into std lib, rather than as standalone module. Somehow
arrange for `use .../standard_library/std.nu` to load this module
without having to put all the source in `std.nu`?
* Maybe command should be `std dirs ...`?
* what else do `enter` and `exit` do that this should do? Then deprecate
those commands.
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.
This is a follow-up from https://github.com/nushell/nushell/pull/8173,
which was merged shortly after the 0.76 release. That PR changed
`default_env.nu` so that the user's home folder is displayed as `~` in
the left prompt. It did so using `get -i`.
This PR just rewrites the Nu code from
https://github.com/nushell/nushell/pull/8173 to use `try`/`catch`
instead of `-i`, which will make it easier to remove the `-i` flags from
`get` and `select` eventually (see
https://github.com/nushell/nushell/pull/8379).
I would like to merge this before the 0.77 release, so we don't end up
with lots of `env.nu` files using `get -i` out in the wild.