Add option to not load std-lib. Default tests to not use std-lib (#8833)

this adds a `--no-std-lib` flag. Moves `nu!` to use the `--no-std-lib`.
Adds a new `nu_with_std!` macro for future tests that need the std-lib.

# 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
- `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 commit is contained in:
JT
2023-04-10 10:55:29 +12:00
committed by GitHub
parent 9e3d6c3bfd
commit 58b96fdede
3 changed files with 174 additions and 3 deletions

View File

@ -103,6 +103,7 @@ pub(crate) fn parse_commandline_args(
#[cfg(feature = "plugin")]
let plugin_file: Option<Expression> = call.get_flag_expr("plugin-config");
let no_config_file = call.get_named_arg("no-config-file");
let no_std_lib = call.get_named_arg("no-std-lib");
let config_file: Option<Expression> = call.get_flag_expr("config");
let env_file: Option<Expression> = call.get_flag_expr("env-config");
let log_level: Option<Expression> = call.get_flag_expr("log-level");
@ -176,6 +177,7 @@ pub(crate) fn parse_commandline_args(
#[cfg(feature = "plugin")]
plugin_file,
no_config_file,
no_std_lib,
config_file,
env_file,
log_level,
@ -211,6 +213,7 @@ pub(crate) struct NushellCliArgs {
#[cfg(feature = "plugin")]
pub(crate) plugin_file: Option<Spanned<String>>,
pub(crate) no_config_file: Option<Spanned<String>>,
pub(crate) no_std_lib: Option<Spanned<String>>,
pub(crate) config_file: Option<Spanned<String>>,
pub(crate) env_file: Option<Spanned<String>>,
pub(crate) log_level: Option<Spanned<String>>,
@ -259,6 +262,7 @@ impl Command for Nu {
"start with no config file and no env file",
Some('n'),
)
.switch("no-std-lib", "start with no standard library", None)
.named(
"threads",
SyntaxShape::Int,