From f27b9db6e3d7b58ff918b7765a41581e202233b4 Mon Sep 17 00:00:00 2001 From: amtoine Date: Sun, 12 Mar 2023 11:36:11 +0100 Subject: [PATCH] remove all previous usage of `enter`, `shells`, `g`, `n` and `p` This commit makes clippy happy. --- crates/nu-command/src/default_context.rs | 5 --- crates/nu-command/src/filesystem/cd.rs | 18 --------- crates/nu-command/src/shells/exit.rs | 50 ++---------------------- 3 files changed, 3 insertions(+), 70 deletions(-) diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 521eb5efce..69405ed376 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -279,12 +279,7 @@ pub fn create_default_context() -> EngineState { // Shells bind_command! { - Enter, Exit, - GotoShell, - NextShell, - PrevShell, - Shells, }; // Formats diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs index 1438f3cae1..15d745980f 100644 --- a/crates/nu-command/src/filesystem/cd.rs +++ b/crates/nu-command/src/filesystem/cd.rs @@ -1,5 +1,4 @@ use crate::filesystem::cd_query::query; -use crate::{get_current_shell, get_shells}; #[cfg(unix)] use libc::gid_t; use nu_engine::{current_dir, CallExt}; @@ -164,23 +163,6 @@ impl Command for Cd { val: path.clone(), span, }; - let cwd = Value::string(cwd.to_string_lossy(), call.head); - - let mut shells = get_shells(engine_state, stack, cwd); - let current_shell = get_current_shell(engine_state, stack); - shells[current_shell] = path_value.clone(); - - stack.add_env_var( - "NUSHELL_SHELLS".into(), - Value::List { - vals: shells, - span: call.head, - }, - ); - stack.add_env_var( - "NUSHELL_CURRENT_SHELL".into(), - Value::int(current_shell as i64, call.head), - ); if let Some(oldpwd) = stack.get_env_var(engine_state, "PWD") { stack.add_env_var("OLDPWD".into(), oldpwd) diff --git a/crates/nu-command/src/shells/exit.rs b/crates/nu-command/src/shells/exit.rs index df947776f0..effcaf935a 100644 --- a/crates/nu-command/src/shells/exit.rs +++ b/crates/nu-command/src/shells/exit.rs @@ -1,10 +1,7 @@ -use super::{get_current_shell, get_last_shell, get_shells}; -use nu_engine::{current_dir, CallExt}; +use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, -}; +use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; #[derive(Clone)] pub struct Exit; @@ -55,48 +52,7 @@ impl Command for Exit { std::process::exit(0); } - let cwd = current_dir(engine_state, stack)?; - let cwd = Value::string(cwd.to_string_lossy(), call.head); - - let mut shells = get_shells(engine_state, stack, cwd); - let mut current_shell = get_current_shell(engine_state, stack); - let mut last_shell = get_last_shell(engine_state, stack); - - shells.remove(current_shell); - - if current_shell <= last_shell { - last_shell = 0; - } - - if current_shell == shells.len() && !shells.is_empty() { - current_shell -= 1; - } - - if shells.is_empty() { - std::process::exit(0); - } else { - let new_path = shells[current_shell].clone(); - - stack.add_env_var( - "NUSHELL_SHELLS".into(), - Value::List { - vals: shells, - span: call.head, - }, - ); - stack.add_env_var( - "NUSHELL_CURRENT_SHELL".into(), - Value::int(current_shell as i64, call.head), - ); - stack.add_env_var( - "NUSHELL_LAST_SHELL".into(), - Value::int(last_shell as i64, call.head), - ); - - stack.add_env_var("PWD".into(), new_path); - - Ok(PipelineData::empty()) - } + std::process::exit(0); } fn examples(&self) -> Vec {