From b82e279f9d72beefc6c3c0445a8cc5bd35857ff9 Mon Sep 17 00:00:00 2001 From: Antoine Stevan <44101798+amtoine@users.noreply.github.com> Date: Thu, 4 May 2023 00:08:07 +0200 Subject: [PATCH] REFACTOR: remove deprecated commands (`old-alias`) (#9056) # Description as stated in the `0.79` release note, this PR removes the `old-alias` and `export old-alias` commands, which were deprecated before. # User-Facing Changes `old-alias` is gone for good :relieved: # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting already mentionned in the `0.79` release note. --- crates/nu-command/src/default_context.rs | 2 - .../src/deprecated/deprecated_commands.rs | 1 + .../src/deprecated/export_old_alias.rs | 59 ---------------- crates/nu-command/src/deprecated/mod.rs | 4 -- crates/nu-command/src/deprecated/old_alias.rs | 68 ------------------- crates/nu-std/lib/help.nu | 8 +-- 6 files changed, 5 insertions(+), 137 deletions(-) delete mode 100644 crates/nu-command/src/deprecated/export_old_alias.rs delete mode 100644 crates/nu-command/src/deprecated/old_alias.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 4b17fa4125..e22d1fdae2 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -438,11 +438,9 @@ pub fn create_default_context() -> EngineState { // Deprecated bind_command! { - ExportOldAlias, HashBase64, LPadDeprecated, MathEvalDeprecated, - OldAlias, RPadDeprecated, StrCollectDeprecated, StrDatetimeDeprecated, diff --git a/crates/nu-command/src/deprecated/deprecated_commands.rs b/crates/nu-command/src/deprecated/deprecated_commands.rs index 6f39ecf3f1..d238ce1890 100644 --- a/crates/nu-command/src/deprecated/deprecated_commands.rs +++ b/crates/nu-command/src/deprecated/deprecated_commands.rs @@ -24,5 +24,6 @@ pub fn deprecated_commands() -> HashMap { ("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()), ]) } diff --git a/crates/nu-command/src/deprecated/export_old_alias.rs b/crates/nu-command/src/deprecated/export_old_alias.rs deleted file mode 100644 index dc630d090d..0000000000 --- a/crates/nu-command/src/deprecated/export_old_alias.rs +++ /dev/null @@ -1,59 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type}; - -#[derive(Clone)] -pub struct ExportOldAlias; - -impl Command for ExportOldAlias { - fn name(&self) -> &str { - "export old-alias" - } - - fn usage(&self) -> &str { - "Define an alias and export it from a module." - } - - fn signature(&self) -> nu_protocol::Signature { - Signature::build("export old-alias") - .input_output_types(vec![(Type::Nothing, Type::Nothing)]) - .required("name", SyntaxShape::String, "name of the alias") - .required( - "initial_value", - SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)), - "equals sign followed by value", - ) - .category(Category::Core) - } - - fn extra_usage(&self) -> &str { - r#"This command is a parser keyword. For details, check: - https://www.nushell.sh/book/thinking_in_nu.html"# - } - - fn is_parser_keyword(&self) -> bool { - true - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - _call: &Call, - _input: PipelineData, - ) -> Result { - Ok(PipelineData::empty()) - } - - fn examples(&self) -> Vec { - vec![Example { - description: "export an alias of ll to ls -l, from a module", - example: "export old-alias ll = ls -l", - result: None, - }] - } - - fn search_terms(&self) -> Vec<&str> { - vec!["aka", "abbr", "module"] - } -} diff --git a/crates/nu-command/src/deprecated/mod.rs b/crates/nu-command/src/deprecated/mod.rs index 241fa159ac..8ab61d6830 100644 --- a/crates/nu-command/src/deprecated/mod.rs +++ b/crates/nu-command/src/deprecated/mod.rs @@ -1,10 +1,8 @@ mod collect; mod deprecated_commands; -mod export_old_alias; mod hash_base64; mod lpad; mod math_eval; -mod old_alias; mod rpad; mod str_datetime; mod str_decimal; @@ -13,11 +11,9 @@ mod str_int; pub use collect::StrCollectDeprecated; pub use deprecated_commands::*; -pub use export_old_alias::ExportOldAlias; pub use hash_base64::HashBase64; pub use lpad::LPadDeprecated; pub use math_eval::SubCommand as MathEvalDeprecated; -pub use old_alias::OldAlias; pub use rpad::RPadDeprecated; pub use str_datetime::StrDatetimeDeprecated; pub use str_decimal::StrDecimalDeprecated; diff --git a/crates/nu-command/src/deprecated/old_alias.rs b/crates/nu-command/src/deprecated/old_alias.rs deleted file mode 100644 index 0077e61ff3..0000000000 --- a/crates/nu-command/src/deprecated/old_alias.rs +++ /dev/null @@ -1,68 +0,0 @@ -use nu_protocol::ast::Call; -use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{ - Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, -}; - -#[derive(Clone)] -pub struct OldAlias; - -impl Command for OldAlias { - fn name(&self) -> &str { - "old-alias" - } - - fn usage(&self) -> &str { - "Alias a command (with optional flags) to a new name." - } - - fn signature(&self) -> nu_protocol::Signature { - Signature::build("old-alias") - .input_output_types(vec![(Type::Nothing, Type::Nothing)]) - .required("name", SyntaxShape::String, "name of the alias") - .required( - "initial_value", - SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)), - "equals sign followed by value", - ) - .category(Category::Core) - } - - fn extra_usage(&self) -> &str { - r#"This command is a parser keyword. For details, check: - https://www.nushell.sh/book/thinking_in_nu.html"# - } - - fn is_parser_keyword(&self) -> bool { - true - } - - fn search_terms(&self) -> Vec<&str> { - vec!["abbr", "aka", "fn", "func", "function"] - } - - fn run( - &self, - _engine_state: &EngineState, - _stack: &mut Stack, - _call: &Call, - _input: PipelineData, - ) -> Result { - Ok(PipelineData::empty()) - } - - fn examples(&self) -> Vec { - vec![ - Example { - description: "Alias ll to ls -l", - example: "old-alias ll = ls -l", - result: Some(Value::nothing(Span::test_data())), - }, - Example { - description: "Make an alias that makes a list of all custom commands", - example: "old-alias customs = ($nu.scope.commands | where is_custom | get command)", - result: Some(Value::nothing(Span::test_data())), - }, - ] - } -} diff --git a/crates/nu-std/lib/help.nu b/crates/nu-std/lib/help.nu index 739d728b67..ef2cf162ff 100644 --- a/crates/nu-std/lib/help.nu +++ b/crates/nu-std/lib/help.nu @@ -285,16 +285,16 @@ def show-alias [alias: record] { # > let us define a bunch of aliases # > ```nushell # > # my foo alias -# > old-alias foo = echo "this is foo" +# > alias foo = echo "this is foo" # > # > # my bar alias -# > old-alias bar = echo "this is bar" +# > alias bar = echo "this is bar" # > # > # my baz alias -# > old-alias baz = echo "this is baz" +# > alias baz = echo "this is baz" # > # > # a multiline alias -# > old-alias multi = echo "this +# > alias multi = echo "this # > is # > a # > multiline