stdlib: use the loaded library in tests and update README (#8811)

Should close #8809.

# Description
this PR uses the automatically loaded library from the tests by
replacing `use std.nu ...` with `use std ...`.

the `README` has been updated by
- removing the very deprencated "concrete examples"
- fixing the `use std` and the "run the tests" sections

the `README` can be previewed
[here](https://github.com/amtoine/nushell/blob/refactor/stdlib/use-std-in-tests-and-update-readme/crates/nu-std/README.md)
👍

# User-Facing Changes
```
$nothing
```

# Tests + Formatting
- 🟢 `toolkit test stdlib`

# After Submitting
```
$nothing
```
This commit is contained in:
Antoine Stevan
2023-04-08 14:35:16 +02:00
committed by GitHub
parent 60e6ea5abd
commit d128c0e02b
7 changed files with 23 additions and 61 deletions

View File

@ -14,42 +14,9 @@ in order to "import" the standard library to either the interactive [*REPL*][REP
`nushell` or inside some `.nu` script, you might want to use the
[`use`](https://nushell.sh/commands/docs/use.html) command!
```bash
use /path/to/standard_library/std.nu
use std
```
> ### :mag: a concrete example
> - my name is @amtoine and i use the `ghq` tool to manage `git` projects
> > **Note**
> > `ghq` stores any repository inside `$env.GHQ_ROOT` under `<host>/<owner>/<repo>/`
> - the path to my local fork of `nushell` is then defined as
> ```bash
> let-env NUSHELL_REPO = ($env.GHQ_ROOT | path join "github.com" "amtoine" "nushell")
> ```
> - and the full path to the standard library is defined as
> ```bash
> let-env STD_LIB = ($env.NUSHELL_REPO | path join "crates" "nu-utils" "standard_library")
> ```
> > see the content of `$env.STD_LIB` :yum:
> > ```bash
> > >_ ls $env.STD_LIB | get name | str replace $env.STD_LIB "" | str trim -l -c "/"
> > ╭───┬───────────╮
> > │ 0 │ README.md │
> > │ 1 │ std.nu │
> > │ 2 │ tests.nu │
> > ╰───┴───────────╯
> > ```
> - finally we can `use` the standard library and have access to the commands it exposes :thumbsup:
> ```bash
> >_ use std.nu
> >_ help std
> Module: std
>
> Exported commands:
> assert (std assert), assert eq (std assert eq), assert ne (std assert ne), match (std match)
>
> This module does not export environment.
> ```
## :pencil2: contribute to the standard library
- all the commands of the standard_library are located in [`std.nu`](std.nu)
- the tests are located in files that have a name starting with "test_", e.g. [`test_std.nu`](test_std.nu)
@ -64,13 +31,8 @@ use /path/to/standard_library/std.nu
### :test_tube: run the tests
the following call should return no errors
```bash
NU_LOG_LEVEL=DEBUG nu /path/to/standard_library/tests.nu
NU_LOG_LEVEL=DEBUG cargo run -- crates/nu-std/tests.nu
```
> #### :mag: a concrete example
> with `STD_LIB` defined as in the example above
> ```bash
> NU_LOG_LEVEL=DEBUG nu ($env.STD_LIB | path join "tests.nu")
> ```
[REPL]: https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop
> **Warning**
> the `cargo run --` part of this command is important to ensure the version of `nushell` and the version of the library are the same.