mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
9e3d6c3bfd
# Description We were seeing duplicate entries for the std lib files, and this PR addresses that. Each file should now only be added once. Note: they are still parsed twice because it's hard to recover the module from the output of `parse` but a bit of clever hacking in a future PR might be able to do that. # User-Facing Changes _(List of all changes that impact the user experience here. This helps us keep track of breaking changes.)_ # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. |
||
---|---|---|
.. | ||
lib | ||
src | ||
tests | ||
Cargo.toml | ||
examples.nu | ||
LICENSE | ||
README.md |
Welcome to the standard library of `nushell`!
The standard library is a pure-nushell
collection of commands to allow anyone to build
complex applications using standardized tools gathered incrementally.
In this library, you might find rust
-like assert
commands to write tests, tools to
manipulate paths and strings, etc, etc, ...
🧰 use the standard library in the REPL or in scripts
in order to "import" the standard library to either the interactive [REPL][REPL] of
nushell
or inside some .nu
script, you might want to use the
use
command!
use std
✏️ contribute to the standard library
- all the commands of the standard_library are located in
std.nu
- the tests are located in files that have a name starting with "test_", e.g.
test_std.nu
- a test runner, at
tests.nu
, allows to run all the tests automatically
🔧 add new commands
- add new standard commands by appending to
std.nu
- add associated tests to
test_std.nu
or preferably totest_<submodule>.nu
.- define a new exported (!)
test_<feature>
command - import the
assert
functions you need at the top of the functions, e.g.use std.nu "assert eq"
- define a new exported (!)
🧪 run the tests
the following call should return no errors
NU_LOG_LEVEL=DEBUG cargo run -- crates/nu-std/tests.nu
Warning
thecargo run --
part of this command is important to ensure the version ofnushell
and the version of the library are the same.