From 560be6e73e61f1ad558d8d889c84fb78eb808fd8 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Sun, 13 Feb 2022 10:30:37 +0800 Subject: [PATCH] feat: mark str to-datetime as deprecated command (#4448) --- crates/nu-command/src/default_context.rs | 1 + crates/nu-command/src/deprecated/mod.rs | 2 ++ .../nu-command/src/deprecated/str_datetime.rs | 36 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 crates/nu-command/src/deprecated/str_datetime.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index ca543083d..108a60295 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -354,6 +354,7 @@ pub fn create_default_context(cwd: impl AsRef) -> EngineState { bind_command! { InsertDeprecated, PivotDeprecated, + StrDatetimeDeprecated, StrDecimalDeprecated, StrIntDeprecated, NthDeprecated, diff --git a/crates/nu-command/src/deprecated/mod.rs b/crates/nu-command/src/deprecated/mod.rs index e70076780..abf7759a8 100644 --- a/crates/nu-command/src/deprecated/mod.rs +++ b/crates/nu-command/src/deprecated/mod.rs @@ -1,6 +1,7 @@ mod insert; mod nth; mod pivot; +mod str_datetime; mod str_decimal; mod str_int; mod unalias; @@ -8,6 +9,7 @@ mod unalias; pub use insert::InsertDeprecated; pub use nth::NthDeprecated; pub use pivot::PivotDeprecated; +pub use str_datetime::StrDatetimeDeprecated; pub use str_decimal::StrDecimalDeprecated; pub use str_int::StrIntDeprecated; pub use unalias::UnaliasDeprecated; diff --git a/crates/nu-command/src/deprecated/str_datetime.rs b/crates/nu-command/src/deprecated/str_datetime.rs new file mode 100644 index 000000000..1faa2b5bf --- /dev/null +++ b/crates/nu-command/src/deprecated/str_datetime.rs @@ -0,0 +1,36 @@ +use nu_protocol::{ + ast::Call, + engine::{Command, EngineState, Stack}, + Category, PipelineData, 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, + )) + } +}