diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index cc4ae16dc..3550cce35 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -167,7 +167,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box Result<(), Box Result<(), Box Result<(), Box { - context.host.lock().print_err(e, &Text::from(prompt_line)); + context.host().lock().print_err(e, &Text::from(prompt_line)); context.clear_errors(); "> ".to_string() } }, Err(e) => { - context.host.lock().print_err(e, &Text::from(prompt_line)); + context.host().lock().print_err(e, &Text::from(prompt_line)); context.clear_errors(); "> ".to_string() @@ -360,7 +361,7 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box Result<(), Box { let config_ctrlc_exit = context - .configs + .configs() .lock() .global_config .as_ref() @@ -400,8 +401,8 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box { - context.shell_manager.remove_at_current(); - if context.shell_manager.is_empty() { + context.shell_manager().remove_at_current(); + if context.shell_manager().is_empty() { break; } } @@ -423,15 +424,15 @@ pub fn cli(context: EvaluationContext, options: Options) -> Result<(), Box { if let Err(err) = context.load_config(&ConfigPath::Local(cfg_path)) { - context.host.lock().print_err(err, &Text::from("")) + context.host().lock().print_err(err, &Text::from("")) } } Err(e) => { //Report error while checking for local cfg file - context.host.lock().print_err(e, &Text::from("")) + context.host().lock().print_err(e, &Text::from("")) } Ok(None) => { //No local cfg file present in start dir @@ -441,7 +442,7 @@ pub fn load_local_cfg_if_present(context: &EvaluationContext) { fn load_cfg_as_global_cfg(context: &EvaluationContext, path: PathBuf) { if let Err(err) = context.load_config(&ConfigPath::Global(path)) { - context.host.lock().print_err(err, &Text::from("")); + context.host().lock().print_err(err, &Text::from("")); } } @@ -451,7 +452,7 @@ pub fn load_global_cfg(context: &EvaluationContext) { load_cfg_as_global_cfg(context, path); } Err(e) => { - context.host.lock().print_err(e, &Text::from("")); + context.host().lock().print_err(e, &Text::from("")); } } } diff --git a/crates/nu-cli/src/line_editor.rs b/crates/nu-cli/src/line_editor.rs index 939ffbf08..658d8e88d 100644 --- a/crates/nu-cli/src/line_editor.rs +++ b/crates/nu-cli/src/line_editor.rs @@ -258,14 +258,14 @@ pub fn rustyline_hinter( pub fn configure_ctrl_c(_context: &EvaluationContext) -> Result<(), Box> { #[cfg(feature = "ctrlc")] { - let cc = _context.ctrl_c.clone(); + let cc = _context.ctrl_c().clone(); ctrlc::set_handler(move || { cc.store(true, Ordering::SeqCst); })?; - if _context.ctrl_c.load(Ordering::SeqCst) { - _context.ctrl_c.store(false, Ordering::SeqCst); + if _context.ctrl_c().load(Ordering::SeqCst) { + _context.ctrl_c().store(false, Ordering::SeqCst); } } diff --git a/crates/nu-cli/src/shell/helper.rs b/crates/nu-cli/src/shell/helper.rs index 49dfc0c2e..5f47bc409 100644 --- a/crates/nu-cli/src/shell/helper.rs +++ b/crates/nu-cli/src/shell/helper.rs @@ -84,7 +84,7 @@ impl rustyline::highlight::Highlighter for Helper { } fn highlight<'l>(&self, line: &'l str, _pos: usize) -> Cow<'l, str> { - let cfg = &self.context.configs.lock(); + let cfg = &self.context.configs().lock(); if let Some(palette) = &cfg.syntax_config { Painter::paint_string(line, &self.context.scope, palette) } else { diff --git a/crates/nu-command/src/commands/autoview/command.rs b/crates/nu-command/src/commands/autoview/command.rs index a0c4bc479..9eb9e4098 100644 --- a/crates/nu-command/src/commands/autoview/command.rs +++ b/crates/nu-command/src/commands/autoview/command.rs @@ -59,7 +59,7 @@ pub fn autoview(args: CommandArgs) -> Result { if let Some(x) = input_stream.next() { match input_stream.next() { Some(y) => { - let ctrl_c = context.ctrl_c.clone(); + let ctrl_c = context.ctrl_c().clone(); let xy = vec![x, y]; let xy_stream = xy.into_iter().chain(input_stream).interruptible(ctrl_c); @@ -192,7 +192,7 @@ pub fn autoview(args: CommandArgs) -> Result { } => { let pivot_mode = configuration.pivot_mode(); - let term_width = context.host.lock().width(); + let term_width = context.host().lock().width(); if pivot_mode.is_always() || (pivot_mode.is_auto() && (row diff --git a/crates/nu-command/src/commands/classified/external.rs b/crates/nu-command/src/commands/classified/external.rs index aec65f570..4d716738b 100644 --- a/crates/nu-command/src/commands/classified/external.rs +++ b/crates/nu-command/src/commands/classified/external.rs @@ -27,7 +27,7 @@ pub(crate) fn run_external_command( trace!(target: "nu::run::external", "-> {}", command.name); context.sync_path_to_env(); - if !context.host.lock().is_external_cmd(&command.name) { + if !context.host().lock().is_external_cmd(&command.name) { return Err(ShellError::labeled_error( "Command not found", format!("command {} not found", &command.name), @@ -59,7 +59,7 @@ fn run_with_stdin( input: InputStream, external_redirection: ExternalRedirection, ) -> Result { - let path = context.shell_manager.path(); + let path = context.shell_manager().path(); let mut command_args = vec![]; for arg in command.args.iter() { diff --git a/crates/nu-command/src/commands/config/get.rs b/crates/nu-command/src/commands/config/get.rs index 0bc52fe6d..023233ed8 100644 --- a/crates/nu-command/src/commands/config/get.rs +++ b/crates/nu-command/src/commands/config/get.rs @@ -41,7 +41,7 @@ pub fn get(args: CommandArgs) -> Result { let column_path = args.req(0)?; - let result = if let Some(global_cfg) = &ctx.configs.lock().global_config { + let result = if let Some(global_cfg) = &ctx.configs().lock().global_config { let result = UntaggedValue::row(global_cfg.vars.clone()).into_value(&name); let value = crate::commands::get::get_column_path(&column_path, &result)?; Ok(match value { diff --git a/crates/nu-command/src/commands/config/remove.rs b/crates/nu-command/src/commands/config/remove.rs index 44e4bf829..d71ecc5c1 100644 --- a/crates/nu-command/src/commands/config/remove.rs +++ b/crates/nu-command/src/commands/config/remove.rs @@ -43,7 +43,7 @@ pub fn remove(args: CommandArgs) -> Result { let key = remove.to_string(); - let result = if let Some(global_cfg) = &mut ctx.configs.lock().global_config { + let result = if let Some(global_cfg) = &mut ctx.configs().lock().global_config { if global_cfg.vars.contains_key(&key) { global_cfg.vars.swap_remove(&key); global_cfg.write()?; diff --git a/crates/nu-command/src/commands/config/set.rs b/crates/nu-command/src/commands/config/set.rs index cb4dd77c6..468fba3aa 100644 --- a/crates/nu-command/src/commands/config/set.rs +++ b/crates/nu-command/src/commands/config/set.rs @@ -57,7 +57,7 @@ pub fn set(args: CommandArgs) -> Result { let column_path = args.req(0)?; let mut value: Value = args.req(1)?; - let result = if let Some(global_cfg) = &mut ctx.configs.lock().global_config { + let result = if let Some(global_cfg) = &mut ctx.configs().lock().global_config { let configuration = UntaggedValue::row(global_cfg.vars.clone()).into_value(&name); if let UntaggedValue::Table(rows) = &value.value { diff --git a/crates/nu-command/src/commands/config/set_into.rs b/crates/nu-command/src/commands/config/set_into.rs index 68c645c52..f49ae71ab 100644 --- a/crates/nu-command/src/commands/config/set_into.rs +++ b/crates/nu-command/src/commands/config/set_into.rs @@ -45,7 +45,7 @@ pub fn set_into(args: CommandArgs) -> Result { let rows: Vec = args.input.collect(); let key = set_into.to_string(); - let result = if let Some(global_cfg) = &mut ctx.configs.lock().global_config { + let result = if let Some(global_cfg) = &mut ctx.configs().lock().global_config { if rows.is_empty() { return Err(ShellError::labeled_error( "No values given for set_into", diff --git a/crates/nu-command/src/commands/dataframe/dtypes.rs b/crates/nu-command/src/commands/dataframe/dtypes.rs index 2080ed085..7ecaae80b 100644 --- a/crates/nu-command/src/commands/dataframe/dtypes.rs +++ b/crates/nu-command/src/commands/dataframe/dtypes.rs @@ -31,6 +31,7 @@ impl WholeStreamCommand for DataFrame { } } +#[allow(clippy::needless_collect)] fn command(mut args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); diff --git a/crates/nu-command/src/commands/enter.rs b/crates/nu-command/src/commands/enter.rs index 5755ffa63..1d1a6ba50 100644 --- a/crates/nu-command/src/commands/enter.rs +++ b/crates/nu-command/src/commands/enter.rs @@ -73,7 +73,7 @@ fn enter(args: CommandArgs) -> Result { let head = args.call_info.args.head.clone(); let context = args.context.clone(); let scope = args.scope().clone(); - let path = args.context.shell_manager.path(); + let path = args.context.shell_manager().path(); let location: Tagged = args.req(0)?; let encoding: Option> = args.get_flag("encoding")?; diff --git a/crates/nu-command/src/commands/history.rs b/crates/nu-command/src/commands/history.rs index eb5115344..5ec589786 100644 --- a/crates/nu-command/src/commands/history.rs +++ b/crates/nu-command/src/commands/history.rs @@ -31,7 +31,7 @@ fn history(args: CommandArgs) -> Result { let clear = args.has_flag("clear"); - let path = if let Some(global_cfg) = &ctx.configs.lock().global_config { + let path = if let Some(global_cfg) = &ctx.configs().lock().global_config { nu_data::config::path::history_path_or_default(global_cfg) } else { nu_data::config::path::default_history_path() diff --git a/crates/nu-command/src/commands/run_external.rs b/crates/nu-command/src/commands/run_external.rs index fd80adfcd..7bf3ccc06 100644 --- a/crates/nu-command/src/commands/run_external.rs +++ b/crates/nu-command/src/commands/run_external.rs @@ -102,7 +102,7 @@ impl WholeStreamCommand for RunExternalCommand { }; let result = external_context - .shell_manager + .shell_manager() .cd(cd_args, args.call_info.name_tag); return Ok(result?.to_action_stream()); @@ -138,7 +138,7 @@ fn maybe_autocd_dir(cmd: &ExternalCommand, ctx: &mut EvaluationContext) -> Optio || (cmd.args.is_empty() && PathBuf::from(name).is_dir() && dunce::canonicalize(name).is_ok() - && !ctx.host.lock().is_external_cmd(name)) + && !ctx.host().lock().is_external_cmd(name)) { Some(name) } else { @@ -151,11 +151,11 @@ fn maybe_autocd_dir(cmd: &ExternalCommand, ctx: &mut EvaluationContext) -> Optio if name.ends_with(':') { // This looks like a drive shortcut. We need to a) switch drives and b) go back to the previous directory we were viewing on that drive // But first, we need to save where we are now - let current_path = ctx.shell_manager.path(); + let current_path = ctx.shell_manager().path(); let split_path: Vec<_> = current_path.split(':').collect(); if split_path.len() > 1 { - ctx.windows_drives_previous_cwd + ctx.windows_drives_previous_cwd() .lock() .insert(split_path[0].to_string(), current_path); } @@ -163,7 +163,7 @@ fn maybe_autocd_dir(cmd: &ExternalCommand, ctx: &mut EvaluationContext) -> Optio let name = name.to_uppercase(); let new_drive: Vec<_> = name.split(':').collect(); - if let Some(val) = ctx.windows_drives_previous_cwd.lock().get(new_drive[0]) { + if let Some(val) = ctx.windows_drives_previous_cwd().lock().get(new_drive[0]) { val.to_string() } else { name diff --git a/crates/nu-engine/src/command_args.rs b/crates/nu-engine/src/command_args.rs index 6e730337d..124ef557e 100644 --- a/crates/nu-engine/src/command_args.rs +++ b/crates/nu-engine/src/command_args.rs @@ -27,23 +27,23 @@ impl CommandArgs { } pub fn host(&self) -> Arc>> { - self.context.host.clone() + self.context.host().clone() } pub fn current_errors(&self) -> Arc>> { - self.context.current_errors.clone() + self.context.current_errors().clone() } pub fn ctrl_c(&self) -> Arc { - self.context.ctrl_c.clone() + self.context.ctrl_c().clone() } pub fn configs(&self) -> Arc> { - self.context.configs.clone() + self.context.configs().clone() } pub fn shell_manager(&self) -> ShellManager { - self.context.shell_manager.clone() + self.context.shell_manager().clone() } pub fn nth(&self, pos: usize) -> Option<&SpannedExpression> { diff --git a/crates/nu-engine/src/evaluate/block.rs b/crates/nu-engine/src/evaluate/block.rs index 852049132..54291c522 100644 --- a/crates/nu-engine/src/evaluate/block.rs +++ b/crates/nu-engine/src/evaluate/block.rs @@ -60,7 +60,7 @@ pub fn run_block( ctx.clear_errors(); return Err(err.clone()); } - if ctx.ctrl_c.load(Ordering::SeqCst) { + if ctx.ctrl_c().load(Ordering::SeqCst) { return Ok(InputStream::empty()); } } @@ -96,7 +96,7 @@ pub fn run_block( ctx.clear_errors(); return Err(err.clone()); } - if ctx.ctrl_c.load(Ordering::SeqCst) { + if ctx.ctrl_c().load(Ordering::SeqCst) { // This early return doesn't return the result // we have so far, but breaking out of this loop // causes lifetime issues. A future contribution diff --git a/crates/nu-engine/src/evaluate/internal.rs b/crates/nu-engine/src/evaluate/internal.rs index f1e050c57..a3f84a28c 100644 --- a/crates/nu-engine/src/evaluate/internal.rs +++ b/crates/nu-engine/src/evaluate/internal.rs @@ -79,7 +79,7 @@ impl Iterator for InternalIterator { match item { Ok(ReturnSuccess::Action(action)) => match action { CommandAction::ChangePath(path) => { - self.context.shell_manager.set_path(path); + self.context.shell_manager().set_path(path); } CommandAction::Exit(code) => std::process::exit(code), // TODO: save history.txt CommandAction::Error(err) => { @@ -135,16 +135,16 @@ impl Iterator for InternalIterator { } CommandAction::EnterValueShell(value) => { self.context - .shell_manager + .shell_manager() .insert_at_current(Box::new(ValueShell::new(value))); } CommandAction::EnterShell(location) => { - let mode = if self.context.shell_manager.is_interactive() { + let mode = if self.context.shell_manager().is_interactive() { FilesystemShellMode::Cli } else { FilesystemShellMode::Script }; - self.context.shell_manager.insert_at_current(Box::new( + self.context.shell_manager().insert_at_current(Box::new( match FilesystemShell::with_location(location, mode) { Ok(v) => v, Err(err) => { @@ -172,14 +172,14 @@ impl Iterator for InternalIterator { } } CommandAction::PreviousShell => { - self.context.shell_manager.prev(); + self.context.shell_manager().prev(); } CommandAction::NextShell => { - self.context.shell_manager.next(); + self.context.shell_manager().next(); } CommandAction::LeaveShell(code) => { - self.context.shell_manager.remove_at_current(); - if self.context.shell_manager.is_empty() { + self.context.shell_manager().remove_at_current(); + if self.context.shell_manager().is_empty() { std::process::exit(code); // TODO: save history.txt } } diff --git a/crates/nu-engine/src/evaluate/variables.rs b/crates/nu-engine/src/evaluate/variables.rs index 5c8afa0fc..fb17269d2 100644 --- a/crates/nu-engine/src/evaluate/variables.rs +++ b/crates/nu-engine/src/evaluate/variables.rs @@ -30,7 +30,7 @@ pub fn nu( UntaggedValue::filepath(default_history_path()).into_value(&tag), ); - if let Some(global_cfg) = &ctx.configs.lock().global_config { + if let Some(global_cfg) = &ctx.configs().lock().global_config { nu_dict.insert_value( "config", UntaggedValue::row(global_cfg.vars.clone()).into_value(&tag), diff --git a/crates/nu-engine/src/evaluation_context.rs b/crates/nu-engine/src/evaluation_context.rs index b0294f9fd..9df9a4c02 100644 --- a/crates/nu-engine/src/evaluation_context.rs +++ b/crates/nu-engine/src/evaluation_context.rs @@ -20,8 +20,7 @@ use std::sync::atomic::AtomicBool; use std::{path::Path, sync::Arc}; #[derive(Clone, Default)] -pub struct EvaluationContext { - pub scope: Scope, +pub struct EngineState { pub host: Arc>>, pub current_errors: Arc>>, pub ctrl_c: Arc, @@ -31,6 +30,11 @@ pub struct EvaluationContext { /// Windows-specific: keep track of previous cwd on each drive pub windows_drives_previous_cwd: Arc>>, } +#[derive(Clone, Default)] +pub struct EvaluationContext { + pub scope: Scope, + engine_state: Arc, +} impl EvaluationContext { pub fn new( @@ -44,12 +48,14 @@ impl EvaluationContext { ) -> Self { Self { scope, - host, - current_errors, - ctrl_c, - configs, - shell_manager, - windows_drives_previous_cwd, + engine_state: Arc::new(EngineState { + host, + current_errors, + ctrl_c, + configs, + shell_manager, + windows_drives_previous_cwd, + }), } } @@ -61,12 +67,14 @@ impl EvaluationContext { EvaluationContext { scope, - host: Arc::new(parking_lot::Mutex::new(Box::new(host))), - current_errors: Arc::new(Mutex::new(vec![])), - ctrl_c: Arc::new(AtomicBool::new(false)), - configs: Arc::new(Mutex::new(ConfigHolder::new())), - shell_manager: ShellManager::basic(), - windows_drives_previous_cwd: Arc::new(Mutex::new(std::collections::HashMap::new())), + engine_state: Arc::new(EngineState { + host: Arc::new(parking_lot::Mutex::new(Box::new(host))), + current_errors: Arc::new(Mutex::new(vec![])), + ctrl_c: Arc::new(AtomicBool::new(false)), + configs: Arc::new(Mutex::new(ConfigHolder::new())), + shell_manager: ShellManager::basic(), + windows_drives_previous_cwd: Arc::new(Mutex::new(std::collections::HashMap::new())), + }), } } @@ -74,12 +82,38 @@ impl EvaluationContext { self.with_errors(|errors| errors.push(error)) } + pub fn host(&self) -> &Arc>> { + &self.engine_state.host + } + + pub fn current_errors(&self) -> &Arc>> { + &self.engine_state.current_errors + } + + pub fn ctrl_c(&self) -> &Arc { + &self.engine_state.ctrl_c + } + + pub fn configs(&self) -> &Arc> { + &self.engine_state.configs + } + + pub fn shell_manager(&self) -> &ShellManager { + &self.engine_state.shell_manager + } + + pub fn windows_drives_previous_cwd( + &self, + ) -> &Arc>> { + &self.engine_state.windows_drives_previous_cwd + } + pub fn clear_errors(&self) { - self.current_errors.lock().clear() + self.engine_state.current_errors.lock().clear() } pub fn get_errors(&self) -> Vec { - self.current_errors.lock().clone() + self.engine_state.current_errors.lock().clone() } pub fn configure( @@ -91,13 +125,13 @@ impl EvaluationContext { } pub fn with_host(&self, block: impl FnOnce(&mut dyn Host) -> T) -> T { - let mut host = self.host.lock(); + let mut host = self.engine_state.host.lock(); block(&mut *host) } pub fn with_errors(&self, block: impl FnOnce(&mut Vec) -> T) -> T { - let mut errors = self.current_errors.lock(); + let mut errors = self.engine_state.current_errors.lock(); block(&mut *errors) } @@ -209,9 +243,9 @@ impl EvaluationContext { self.scope.set_exit_scripts(exit_scripts); match cfg_path { - ConfigPath::Global(_) => self.configs.lock().set_global_cfg(cfg), + ConfigPath::Global(_) => self.engine_state.configs.lock().set_global_cfg(cfg), ConfigPath::Local(_) => { - self.configs.lock().add_local_cfg(cfg); + self.engine_state.configs.lock().add_local_cfg(cfg); } } @@ -221,7 +255,7 @@ impl EvaluationContext { // folder as the config.toml // Let's open the config - let global_config = self.configs.lock().global_config(); + let global_config = self.engine_state.configs.lock().global_config(); // Get the root syntax_theme value let syntax_theme = global_config.var("syntax_theme"); // If we have a syntax_theme let's process it @@ -246,16 +280,18 @@ impl EvaluationContext { let mut reader = BufReader::new(syntax_theme_file); let theme = ThemedPalette::new(&mut reader).unwrap_or_default(); // eprintln!("Theme: [{:?}]", theme); - self.configs.lock().set_syntax_colors(theme); + self.engine_state.configs.lock().set_syntax_colors(theme); } else { // If the file was missing, use the default - self.configs + self.engine_state + .configs .lock() .set_syntax_colors(ThemedPalette::default()) } } else { // if there's no syntax_theme, use the default - self.configs + self.engine_state + .configs .lock() .set_syntax_colors(ThemedPalette::default()) }; @@ -336,7 +372,7 @@ impl EvaluationContext { } //Unload config - self.configs.lock().remove_cfg(cfg_path); + self.engine_state.configs.lock().remove_cfg(cfg_path); self.scope.exit_scope_with_tag(&tag); } @@ -353,7 +389,7 @@ impl EvaluationContext { e )); let text = script.into(); - self.host.lock().print_err(err, &text); + self.engine_state.host.lock().print_err(err, &text); } } } diff --git a/crates/nu-engine/src/print.rs b/crates/nu-engine/src/print.rs index 87f36e93a..f1072a472 100644 --- a/crates/nu-engine/src/print.rs +++ b/crates/nu-engine/src/print.rs @@ -3,14 +3,14 @@ use nu_source::Text; use crate::EvaluationContext; pub fn maybe_print_errors(context: &EvaluationContext, source: Text) -> bool { - let errors = context.current_errors.clone(); + let errors = context.current_errors().clone(); let mut errors = errors.lock(); if errors.len() > 0 { let error = errors[0].clone(); *errors = vec![]; - context.host.lock().print_err(error, &source); + context.host().lock().print_err(error, &source); true } else { false diff --git a/crates/nu-engine/src/script.rs b/crates/nu-engine/src/script.rs index bf01e9b7a..5f1cdf971 100644 --- a/crates/nu-engine/src/script.rs +++ b/crates/nu-engine/src/script.rs @@ -42,12 +42,12 @@ pub fn run_script_in_dir( ctx: &EvaluationContext, ) -> Result<(), Box> { //Save path before to switch back to it after executing script - let path_before = ctx.shell_manager.path(); + let path_before = ctx.shell_manager().path(); - ctx.shell_manager + ctx.shell_manager() .set_path(dir.to_string_lossy().to_string()); run_script_standalone(script, false, ctx, false)?; - ctx.shell_manager.set_path(path_before); + ctx.shell_manager().set_path(path_before); Ok(()) } @@ -118,9 +118,9 @@ pub fn process_script( .as_ref() .map(NamedArguments::is_empty) .unwrap_or(true) - && canonicalize(ctx.shell_manager.path(), name).is_ok() + && canonicalize(ctx.shell_manager().path(), name).is_ok() && Path::new(&name).is_dir() - && !ctx.host.lock().is_external_cmd(name) + && !ctx.host().lock().is_external_cmd(name) { let tag = Tag { anchor: Some(AnchorLocation::Source(line.into())), @@ -133,11 +133,11 @@ pub fn process_script( if name.ends_with(':') { // This looks like a drive shortcut. We need to a) switch drives and b) go back to the previous directory we were viewing on that drive // But first, we need to save where we are now - let current_path = ctx.shell_manager.path(); + let current_path = ctx.shell_manager().path(); let split_path: Vec<_> = current_path.split(':').collect(); if split_path.len() > 1 { - ctx.windows_drives_previous_cwd + ctx.windows_drives_previous_cwd() .lock() .insert(split_path[0].to_string(), current_path); } @@ -146,7 +146,7 @@ pub fn process_script( let new_drive: Vec<_> = name.split(':').collect(); if let Some(val) = - ctx.windows_drives_previous_cwd.lock().get(new_drive[0]) + ctx.windows_drives_previous_cwd().lock().get(new_drive[0]) { val.to_string() } else { @@ -169,7 +169,7 @@ pub fn process_script( }), }; - return match ctx.shell_manager.cd(cd_args, tag) { + return match ctx.shell_manager().cd(cd_args, tag) { Err(e) => LineResult::Error(line.to_string(), e), Ok(stream) => { let iter = InternalIterator { @@ -244,7 +244,7 @@ pub fn process_script( .. }) => return LineResult::Error(line.to_string(), e), Some(_item) => { - if ctx.ctrl_c.load(Ordering::SeqCst) { + if ctx.ctrl_c().load(Ordering::SeqCst) { break; } } @@ -267,7 +267,7 @@ pub fn run_script_standalone( exit_on_error: bool, ) -> Result<(), Box> { context - .shell_manager + .shell_manager() .enter_script_mode() .map_err(Box::new)?; let line = process_script(&script_text, context, redirect_stdin, 0, false); @@ -275,7 +275,7 @@ pub fn run_script_standalone( match line { LineResult::Success(line) => { let error_code = { - let errors = context.current_errors.clone(); + let errors = context.current_errors().clone(); let errors = errors.lock(); if errors.len() > 0 { @@ -293,7 +293,7 @@ pub fn run_script_standalone( LineResult::Error(line, err) => { context - .host + .host() .lock() .print_err(err, &Text::from(line.clone())); @@ -307,7 +307,7 @@ pub fn run_script_standalone( } //exit script mode shell - context.shell_manager.remove_at_current(); + context.shell_manager().remove_at_current(); Ok(()) } diff --git a/crates/nu-protocol/src/dataframe/nu_dataframe.rs b/crates/nu-protocol/src/dataframe/nu_dataframe.rs index 12e2974cf..cd029e862 100644 --- a/crates/nu-protocol/src/dataframe/nu_dataframe.rs +++ b/crates/nu-protocol/src/dataframe/nu_dataframe.rs @@ -134,6 +134,7 @@ impl NuDataFrame { from_parsed_columns(column_values, tag) } + #[allow(clippy::clippy::wrong_self_convention)] pub fn to_value(self, tag: Tag) -> Value { Value { value: UntaggedValue::DataFrame(PolarsData::EagerDataFrame(self)), diff --git a/crates/nu-protocol/src/dataframe/nu_series.rs b/crates/nu-protocol/src/dataframe/nu_series.rs index a30107113..08d95d821 100644 --- a/crates/nu-protocol/src/dataframe/nu_series.rs +++ b/crates/nu-protocol/src/dataframe/nu_series.rs @@ -97,6 +97,7 @@ impl NuSeries { from_parsed_vector(vec_values, name) } + #[allow(clippy::clippy::wrong_self_convention)] pub fn to_value(self, tag: Tag) -> Value { Value { value: UntaggedValue::DataFrame(PolarsData::Series(self)),