From dcb1a1996ccdca419e11f1ded5afacac2dfea58d Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Sun, 6 Aug 2023 13:42:16 +0200 Subject: [PATCH] remove old deprecated commands (#9840) # Description in this PR i propose to remove the following old deprecated commands - `hash base64` -> `encode base64` - `math eval` -> `math ` - `str to-datetime` -> `into datetime` - `str to-decimal` -> `into decimal` - `str find-replace` -> `str replace` - `str to-int` -> `into int` - `keep` -> `take` - `match` -> `find` - `nth` -> `select` - `pivot` -> `transpose` - `unalias` -> `hide` - `all?` -> `all` - `any?` -> `any` - `empty?` -> `is-empty` - `build-string` -> `str join` / string concatenation with `+` - `str lpad` -> `fill` - `str rpad` -> `fill` - `str collect` -> `str join` - `old-alias` -> `alias` so old i do not remember them at all :open_mouth: i left the following four commands because they have been moved much more recently i think! - `fetch` -> `http get` - `post` -> `http post` - `benchmark` -> `timeit` - `let-env` - `date format` -> `format date` # User-Facing Changes # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :black_circle: `toolkit test` - :black_circle: `toolkit test stdlib` # After Submitting --- crates/nu-command/src/charting/histogram.rs | 0 crates/nu-command/src/default_context.rs | 13 +----- crates/nu-command/src/deprecated/collect.rs | 34 ---------------- .../src/deprecated/deprecated_commands.rs | 16 -------- .../nu-command/src/deprecated/hash_base64.rs | 34 ---------------- crates/nu-command/src/deprecated/let_env.rs | 4 +- crates/nu-command/src/deprecated/lpad.rs | 35 ---------------- crates/nu-command/src/deprecated/math_eval.rs | 40 ------------------- crates/nu-command/src/deprecated/mod.rs | 20 +--------- crates/nu-command/src/deprecated/rpad.rs | 35 ---------------- .../nu-command/src/deprecated/str_datetime.rs | 36 ----------------- .../nu-command/src/deprecated/str_decimal.rs | 36 ----------------- .../src/deprecated/str_find_replace.rs | 36 ----------------- crates/nu-command/src/deprecated/str_int.rs | 36 ----------------- 14 files changed, 5 insertions(+), 370 deletions(-) mode change 100644 => 100755 crates/nu-command/src/charting/histogram.rs delete mode 100644 crates/nu-command/src/deprecated/collect.rs delete mode 100644 crates/nu-command/src/deprecated/hash_base64.rs delete mode 100644 crates/nu-command/src/deprecated/lpad.rs delete mode 100644 crates/nu-command/src/deprecated/math_eval.rs delete mode 100644 crates/nu-command/src/deprecated/rpad.rs delete mode 100644 crates/nu-command/src/deprecated/str_datetime.rs delete mode 100644 crates/nu-command/src/deprecated/str_decimal.rs delete mode 100644 crates/nu-command/src/deprecated/str_find_replace.rs delete mode 100644 crates/nu-command/src/deprecated/str_int.rs diff --git a/crates/nu-command/src/charting/histogram.rs b/crates/nu-command/src/charting/histogram.rs old mode 100644 new mode 100755 diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 5cb1a6edc7..1c39988178 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -299,8 +299,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { // Env bind_command! { - LetEnvDeprecated, - DateFormat, ExportEnv, LoadEnv, SourceEnv, @@ -382,15 +380,8 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState { // Deprecated bind_command! { - HashBase64, - LPadDeprecated, - MathEvalDeprecated, - RPadDeprecated, - StrCollectDeprecated, - StrDatetimeDeprecated, - StrDecimalDeprecated, - StrFindReplaceDeprecated, - StrIntDeprecated, + LetEnv, + DateFormat, }; working_set.render() diff --git a/crates/nu-command/src/deprecated/collect.rs b/crates/nu-command/src/deprecated/collect.rs deleted file mode 100644 index 8e1b359a4f..0000000000 --- a/crates/nu-command/src/deprecated/collect.rs +++ /dev/null @@ -1,34 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, PipelineData, ShellError, Signature}; - -#[derive(Clone)] -pub struct StrCollectDeprecated; - -impl Command for StrCollectDeprecated { - fn name(&self) -> &str { - "str collect" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _: &EngineState, - _: &mut Stack, - call: &Call, - _: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "str join".to_owned(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/deprecated_commands.rs b/crates/nu-command/src/deprecated/deprecated_commands.rs index 933b2a1d8c..7a9e9a33e2 100644 --- a/crates/nu-command/src/deprecated/deprecated_commands.rs +++ b/crates/nu-command/src/deprecated/deprecated_commands.rs @@ -6,25 +6,9 @@ use std::collections::HashMap; /// For those, it's currently easiest to have a "stub" command that just returns an error. pub fn deprecated_commands() -> HashMap { [ - ("keep".to_string(), "take".to_string()), - ("match".to_string(), "find".to_string()), - ("nth".to_string(), "select".to_string()), - ("pivot".to_string(), "transpose".to_string()), - ("unalias".to_string(), "hide".to_string()), - ("all?".to_string(), "all".to_string()), - ("any?".to_string(), "any".to_string()), - ("empty?".to_string(), "is-empty".to_string()), - ( - "build-string".to_string(), - "str join'/'string concatenation with '+'".to_string(), - ), ("fetch".to_string(), "http get".to_string()), ("post".to_string(), "http post".to_string()), - ("str lpad".to_string(), "fill".to_string()), - ("str rpad".to_string(), "fill".to_string()), ("benchmark".to_string(), "timeit".to_string()), - ("str collect".to_string(), "str join".to_string()), - ("old-alias".to_string(), "alias".to_string()), ] .into_iter() .collect() diff --git a/crates/nu-command/src/deprecated/hash_base64.rs b/crates/nu-command/src/deprecated/hash_base64.rs deleted file mode 100644 index 1d5b23f934..0000000000 --- a/crates/nu-command/src/deprecated/hash_base64.rs +++ /dev/null @@ -1,34 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, PipelineData, ShellError, Signature}; - -#[derive(Clone)] -pub struct HashBase64; - -impl Command for HashBase64 { - fn name(&self) -> &str { - "hash base64" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _: &EngineState, - _: &mut Stack, - call: &Call, - _: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "encode base64".to_owned(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/let_env.rs b/crates/nu-command/src/deprecated/let_env.rs index 36192b5922..f7eac58ad9 100644 --- a/crates/nu-command/src/deprecated/let_env.rs +++ b/crates/nu-command/src/deprecated/let_env.rs @@ -3,9 +3,9 @@ use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type}; #[derive(Clone)] -pub struct LetEnvDeprecated; +pub struct LetEnv; -impl Command for LetEnvDeprecated { +impl Command for LetEnv { fn name(&self) -> &str { "let-env" } diff --git a/crates/nu-command/src/deprecated/lpad.rs b/crates/nu-command/src/deprecated/lpad.rs deleted file mode 100644 index fcc401f8ad..0000000000 --- a/crates/nu-command/src/deprecated/lpad.rs +++ /dev/null @@ -1,35 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{PipelineData, ShellError, Signature}; - -#[derive(Clone)] -pub struct LPadDeprecated; - -impl Command for LPadDeprecated { - fn name(&self) -> &str { - "str lpad" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _: &EngineState, - _: &mut Stack, - call: &Call, - _: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "fill".to_owned(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/math_eval.rs b/crates/nu-command/src/deprecated/math_eval.rs deleted file mode 100644 index 2264a99c21..0000000000 --- a/crates/nu-command/src/deprecated/math_eval.rs +++ /dev/null @@ -1,40 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape}; - -#[derive(Clone)] -pub struct SubCommand; - -impl Command for SubCommand { - fn name(&self) -> &str { - "math eval" - } - - fn signature(&self) -> Signature { - Signature::build("math eval") - .rest( - "ignored", - SyntaxShape::Any, - "arguments to deprecated command are ignored", - ) - .category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - call: &Call, - _input: PipelineData, - ) -> Result { - Err(ShellError::DeprecatedCommand( - self.name().to_string(), - "math ".to_string(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/mod.rs b/crates/nu-command/src/deprecated/mod.rs index d72efcee85..9d4afc642a 100644 --- a/crates/nu-command/src/deprecated/mod.rs +++ b/crates/nu-command/src/deprecated/mod.rs @@ -1,25 +1,7 @@ -mod collect; mod deprecated_commands; mod format; -mod hash_base64; mod let_env; -mod lpad; -mod math_eval; -mod rpad; -mod str_datetime; -mod str_decimal; -mod str_find_replace; -mod str_int; -pub use collect::StrCollectDeprecated; pub use deprecated_commands::*; pub use format::SubCommand as DateFormat; -pub use hash_base64::HashBase64; -pub use let_env::LetEnvDeprecated; -pub use lpad::LPadDeprecated; -pub use math_eval::SubCommand as MathEvalDeprecated; -pub use rpad::RPadDeprecated; -pub use str_datetime::StrDatetimeDeprecated; -pub use str_decimal::StrDecimalDeprecated; -pub use str_find_replace::StrFindReplaceDeprecated; -pub use str_int::StrIntDeprecated; +pub use let_env::LetEnv; diff --git a/crates/nu-command/src/deprecated/rpad.rs b/crates/nu-command/src/deprecated/rpad.rs deleted file mode 100644 index 890b358ffc..0000000000 --- a/crates/nu-command/src/deprecated/rpad.rs +++ /dev/null @@ -1,35 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::Category; -use nu_protocol::{PipelineData, ShellError, Signature}; - -#[derive(Clone)] -pub struct RPadDeprecated; - -impl Command for RPadDeprecated { - fn name(&self) -> &str { - "str rpad" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _: &EngineState, - _: &mut Stack, - call: &Call, - _: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "fill".to_owned(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/str_datetime.rs b/crates/nu-command/src/deprecated/str_datetime.rs deleted file mode 100644 index 33bca9fc92..0000000000 --- a/crates/nu-command/src/deprecated/str_datetime.rs +++ /dev/null @@ -1,36 +0,0 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, PipelineData, ShellError, Signature, -}; - -#[derive(Clone)] -pub struct StrDatetimeDeprecated; - -impl Command for StrDatetimeDeprecated { - fn name(&self) -> &str { - "str to-datetime" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - call: &Call, - _input: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "into datetime".to_string(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/str_decimal.rs b/crates/nu-command/src/deprecated/str_decimal.rs deleted file mode 100644 index 9163b86bd4..0000000000 --- a/crates/nu-command/src/deprecated/str_decimal.rs +++ /dev/null @@ -1,36 +0,0 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, PipelineData, ShellError, Signature, -}; - -#[derive(Clone)] -pub struct StrDecimalDeprecated; - -impl Command for StrDecimalDeprecated { - fn name(&self) -> &str { - "str to-decimal" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - call: &Call, - _input: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "into decimal".to_string(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/str_find_replace.rs b/crates/nu-command/src/deprecated/str_find_replace.rs deleted file mode 100644 index 093b56668c..0000000000 --- a/crates/nu-command/src/deprecated/str_find_replace.rs +++ /dev/null @@ -1,36 +0,0 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, PipelineData, ShellError, Signature, -}; - -#[derive(Clone)] -pub struct StrFindReplaceDeprecated; - -impl Command for StrFindReplaceDeprecated { - fn name(&self) -> &str { - "str find-replace" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - call: &Call, - _input: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "str replace".to_string(), - call.head, - )) - } -} diff --git a/crates/nu-command/src/deprecated/str_int.rs b/crates/nu-command/src/deprecated/str_int.rs deleted file mode 100644 index be609778fb..0000000000 --- a/crates/nu-command/src/deprecated/str_int.rs +++ /dev/null @@ -1,36 +0,0 @@ -use nu_protocol::{ - ast::Call, - engine::{Command, EngineState, Stack}, - Category, PipelineData, ShellError, Signature, -}; - -#[derive(Clone)] -pub struct StrIntDeprecated; - -impl Command for StrIntDeprecated { - fn name(&self) -> &str { - "str to-int" - } - - fn signature(&self) -> Signature { - Signature::build(self.name()).category(Category::Deprecated) - } - - fn usage(&self) -> &str { - "Deprecated command." - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - call: &Call, - _input: PipelineData, - ) -> Result { - Err(nu_protocol::ShellError::DeprecatedCommand( - self.name().to_string(), - "into int".to_string(), - call.head, - )) - } -}