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 <sub>`
- `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 😮

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
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

# After Submitting
This commit is contained in:
Antoine Stevan 2023-08-06 13:42:16 +02:00 committed by GitHub
parent 6b4d06d8a7
commit dcb1a1996c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 5 additions and 370 deletions

0
crates/nu-command/src/charting/histogram.rs Normal file → Executable file
View File

View File

@ -299,8 +299,6 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
// Env // Env
bind_command! { bind_command! {
LetEnvDeprecated,
DateFormat,
ExportEnv, ExportEnv,
LoadEnv, LoadEnv,
SourceEnv, SourceEnv,
@ -382,15 +380,8 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
// Deprecated // Deprecated
bind_command! { bind_command! {
HashBase64, LetEnv,
LPadDeprecated, DateFormat,
MathEvalDeprecated,
RPadDeprecated,
StrCollectDeprecated,
StrDatetimeDeprecated,
StrDecimalDeprecated,
StrFindReplaceDeprecated,
StrIntDeprecated,
}; };
working_set.render() working_set.render()

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"str join".to_owned(),
call.head,
))
}
}

View File

@ -6,25 +6,9 @@ use std::collections::HashMap;
/// For those, it's currently easiest to have a "stub" command that just returns an error. /// For those, it's currently easiest to have a "stub" command that just returns an error.
pub fn deprecated_commands() -> HashMap<String, String> { pub fn deprecated_commands() -> HashMap<String, String> {
[ [
("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()), ("fetch".to_string(), "http get".to_string()),
("post".to_string(), "http post".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()), ("benchmark".to_string(), "timeit".to_string()),
("str collect".to_string(), "str join".to_string()),
("old-alias".to_string(), "alias".to_string()),
] ]
.into_iter() .into_iter()
.collect() .collect()

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"encode base64".to_owned(),
call.head,
))
}
}

View File

@ -3,9 +3,9 @@ use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type}; use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type};
#[derive(Clone)] #[derive(Clone)]
pub struct LetEnvDeprecated; pub struct LetEnv;
impl Command for LetEnvDeprecated { impl Command for LetEnv {
fn name(&self) -> &str { fn name(&self) -> &str {
"let-env" "let-env"
} }

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"fill".to_owned(),
call.head,
))
}
}

View File

@ -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<PipelineData, ShellError> {
Err(ShellError::DeprecatedCommand(
self.name().to_string(),
"math <subcommands>".to_string(),
call.head,
))
}
}

View File

@ -1,25 +1,7 @@
mod collect;
mod deprecated_commands; mod deprecated_commands;
mod format; mod format;
mod hash_base64;
mod let_env; 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 deprecated_commands::*;
pub use format::SubCommand as DateFormat; pub use format::SubCommand as DateFormat;
pub use hash_base64::HashBase64; pub use let_env::LetEnv;
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;

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"fill".to_owned(),
call.head,
))
}
}

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"into datetime".to_string(),
call.head,
))
}
}

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"into decimal".to_string(),
call.head,
))
}
}

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"str replace".to_string(),
call.head,
))
}
}

View File

@ -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<PipelineData, ShellError> {
Err(nu_protocol::ShellError::DeprecatedCommand(
self.name().to_string(),
"into int".to_string(),
call.head,
))
}
}