mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 23:22:32 +02:00
Move script to nu engine (#3092)
* Move run_script to engine * Add which dep and feature to engine * Change unwrap to expect * Add wasm specification * Remove which from default, add specification correctly * Add nu-platform-specifics * Move is_external_cmd to platform_specifics * Add is_external_cmd to host and use it instead of nu_platform directly * Clean up if else logic in is_external_cmd * Bump nu-platform-specifics version * Pass context to print_err * Commit cargo.lock * Move print functions to own module inside nu-engine * Hypocratic change to run windows-nightly again * Add import for Ordering * Move printing of error to host * Move platform specific which functionality to basic host * Allow no use of cmd_name * Fix windows compile issue
This commit is contained in:
@ -1,12 +1,11 @@
|
||||
use crate::line_editor::configure_ctrl_c;
|
||||
use nu_command::commands::default_context::create_default_context;
|
||||
#[allow(unused_imports)]
|
||||
use nu_command::maybe_print_errors;
|
||||
use nu_engine::run_block;
|
||||
use nu_engine::EvaluationContext;
|
||||
use nu_engine::{
|
||||
print::maybe_print_errors, run_block, script::run_script_standalone, EvaluationContext,
|
||||
};
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use nu_command::script::{process_script, LineResult};
|
||||
pub(crate) use nu_engine::script::{process_script, LineResult};
|
||||
|
||||
#[cfg(feature = "rustyline-support")]
|
||||
use crate::line_editor::{
|
||||
@ -21,8 +20,6 @@ use nu_stream::InputStream;
|
||||
#[allow(unused_imports)]
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use nu_command::script::{print_err, run_script_standalone};
|
||||
|
||||
#[cfg(feature = "rustyline-support")]
|
||||
use rustyline::{self, error::ReadlineError};
|
||||
|
||||
@ -79,7 +76,7 @@ pub async fn run_script_file(
|
||||
syncer.sync_path_vars(ctx);
|
||||
|
||||
if let Err(reason) = syncer.autoenv(ctx) {
|
||||
print_err(reason, &Text::from(""), ctx);
|
||||
ctx.host.lock().print_err(reason, &Text::from(""));
|
||||
}
|
||||
|
||||
let _ = register_plugins(ctx);
|
||||
@ -107,7 +104,7 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
|
||||
syncer.sync_path_vars(ctx);
|
||||
|
||||
if let Err(reason) = syncer.autoenv(ctx) {
|
||||
print_err(reason, &Text::from(""), ctx);
|
||||
ctx.host.lock().print_err(reason, &Text::from(""));
|
||||
}
|
||||
|
||||
let _ = configure_ctrl_c(ctx);
|
||||
@ -199,14 +196,14 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
crate::cli::print_err(e, &Text::from(prompt_line), &context);
|
||||
context.host.lock().print_err(e, &Text::from(prompt_line));
|
||||
context.clear_errors();
|
||||
|
||||
"> ".to_string()
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
crate::cli::print_err(e, &Text::from(prompt_line), &context);
|
||||
context.host.lock().print_err(e, &Text::from(prompt_line));
|
||||
context.clear_errors();
|
||||
|
||||
"> ".to_string()
|
||||
@ -274,7 +271,7 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
|
||||
if let Err(reason) = syncer.autoenv(ctx) {
|
||||
print_err(reason, &Text::from(""), ctx);
|
||||
ctx.host.lock().print_err(reason, &Text::from(""));
|
||||
}
|
||||
|
||||
let _ = configure_rustyline_editor(&mut rl, config);
|
||||
@ -296,7 +293,10 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
|
||||
rl.add_history_entry(&line);
|
||||
let _ = rl.save_history(&history_path);
|
||||
|
||||
print_err(err, &Text::from(session_text.clone()), &context);
|
||||
context
|
||||
.host
|
||||
.lock()
|
||||
.print_err(err, &Text::from(session_text.clone()));
|
||||
|
||||
maybe_print_errors(&context, Text::from(session_text.clone()));
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::error::Error;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use nu_command::script::LineResult;
|
||||
use nu_engine::script::LineResult;
|
||||
|
||||
#[cfg(feature = "rustyline-support")]
|
||||
use crate::shell::Helper;
|
||||
|
Reference in New Issue
Block a user