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 😌 

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
already mentionned in the `0.79` release note.
This commit is contained in:
Antoine Stevan 2023-05-04 00:08:07 +02:00 committed by GitHub
parent 6bbe5b6255
commit b82e279f9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 137 deletions

View File

@ -438,11 +438,9 @@ pub fn create_default_context() -> EngineState {
// Deprecated
bind_command! {
ExportOldAlias,
HashBase64,
LPadDeprecated,
MathEvalDeprecated,
OldAlias,
RPadDeprecated,
StrCollectDeprecated,
StrDatetimeDeprecated,

View File

@ -24,5 +24,6 @@ pub fn deprecated_commands() -> HashMap<String, 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()),
])
}

View File

@ -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<PipelineData, ShellError> {
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {
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"]
}
}

View File

@ -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;

View File

@ -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<PipelineData, ShellError> {
Ok(PipelineData::empty())
}
fn examples(&self) -> Vec<Example> {
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())),
},
]
}
}

View File

@ -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