Skip to content

Commit bdaa326

Browse files
authored
REFACTOR: have a single std loading call (#9033)
# Description this PR moves the three individual call to `load_standard_library` in the "Nushell branches" of `run.rs` into a single one, before the `if`, in `main.rs`. # User-Facing Changes ``` $nothing ``` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - ⚫ `toolkit test` - ⚫ `toolkit test stdlib` # After Submitting ``` $nothing ```
1 parent 9804cd8 commit bdaa326

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use nu_cli::gather_parent_env_vars;
2222
use nu_command::{create_default_context, get_init_cwd};
2323
use nu_protocol::{report_error_new, Value};
2424
use nu_protocol::{util::BufferedReader, PipelineData, RawStream};
25+
use nu_std::load_standard_library;
2526
use nu_utils::utils::perf;
2627
use run::{run_commands, run_file, run_repl};
2728
use signals::{ctrlc_protection, sigquit_protection};
@@ -250,6 +251,10 @@ fn main() -> Result<()> {
250251
use_color,
251252
);
252253

254+
if parsed_nu_cli_args.no_std_lib.is_none() {
255+
load_standard_library(&mut engine_state)?;
256+
}
257+
253258
if let Some(commands) = parsed_nu_cli_args.commands.clone() {
254259
run_commands(
255260
&mut engine_state,

src/run.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::{
88
use nu_cli::read_plugin_file;
99
use nu_cli::{evaluate_commands, evaluate_file, evaluate_repl};
1010
use nu_protocol::PipelineData;
11-
use nu_std::load_standard_library;
1211
use nu_utils::utils::perf;
1312

1413
pub(crate) fn run_commands(
@@ -22,10 +21,6 @@ pub(crate) fn run_commands(
2221
let mut stack = nu_protocol::engine::Stack::new();
2322
let start_time = std::time::Instant::now();
2423

25-
if parsed_nu_cli_args.no_std_lib.is_none() {
26-
load_standard_library(engine_state)?;
27-
}
28-
2924
#[cfg(feature = "plugin")]
3025
read_plugin_file(
3126
engine_state,
@@ -113,10 +108,6 @@ pub(crate) fn run_file(
113108
let mut stack = nu_protocol::engine::Stack::new();
114109
let start_time = std::time::Instant::now();
115110

116-
if parsed_nu_cli_args.no_std_lib.is_none() {
117-
load_standard_library(engine_state)?;
118-
}
119-
120111
#[cfg(feature = "plugin")]
121112
read_plugin_file(
122113
engine_state,
@@ -214,10 +205,6 @@ pub(crate) fn run_repl(
214205
let mut stack = nu_protocol::engine::Stack::new();
215206
let start_time = std::time::Instant::now();
216207

217-
if parsed_nu_cli_args.no_std_lib.is_none() {
218-
load_standard_library(engine_state)?;
219-
}
220-
221208
if parsed_nu_cli_args.no_config_file.is_none() {
222209
setup_config(
223210
engine_state,

0 commit comments

Comments
 (0)