From baf6348e663b8d7ef1a047b706f3c409f61961db Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Sat, 12 Feb 2022 23:06:52 +0800 Subject: [PATCH] feat: add unalias to deprecated command (#4440) --- crates/nu-command/src/default_context.rs | 1 + crates/nu-command/src/deprecated/mod.rs | 2 ++ crates/nu-command/src/deprecated/unalias.rs | 36 +++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 crates/nu-command/src/deprecated/unalias.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 3341e674a6..ca543083df 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -357,6 +357,7 @@ pub fn create_default_context(cwd: impl AsRef) -> EngineState { StrDecimalDeprecated, StrIntDeprecated, NthDeprecated, + UnaliasDeprecated, }; #[cfg(feature = "dataframe")] diff --git a/crates/nu-command/src/deprecated/mod.rs b/crates/nu-command/src/deprecated/mod.rs index 1533ced003..e70076780e 100644 --- a/crates/nu-command/src/deprecated/mod.rs +++ b/crates/nu-command/src/deprecated/mod.rs @@ -3,12 +3,14 @@ mod nth; mod pivot; mod str_decimal; mod str_int; +mod unalias; pub use insert::InsertDeprecated; pub use nth::NthDeprecated; pub use pivot::PivotDeprecated; pub use str_decimal::StrDecimalDeprecated; pub use str_int::StrIntDeprecated; +pub use unalias::UnaliasDeprecated; #[cfg(feature = "dataframe")] mod dataframe; diff --git a/crates/nu-command/src/deprecated/unalias.rs b/crates/nu-command/src/deprecated/unalias.rs new file mode 100644 index 0000000000..6cffc40ceb --- /dev/null +++ b/crates/nu-command/src/deprecated/unalias.rs @@ -0,0 +1,36 @@ +use nu_protocol::{ + ast::Call, + engine::{Command, EngineState, Stack}, + Category, PipelineData, Signature, +}; + +#[derive(Clone)] +pub struct UnaliasDeprecated; + +impl Command for UnaliasDeprecated { + fn name(&self) -> &str { + "unalias" + } + + 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(), + "hide".to_string(), + call.head, + )) + } +}