mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:55:40 +02:00
Rename misused "deprecation" to removal (#10000)
# Description In the past we named the process of completely removing a command and providing a basic error message pointing to the new alternative "deprecation". But this doesn't match the expectation of most users that have seen deprecation _warnings_ that alert to either impending removal or discouraged use after a stability promise. # User-Facing Changes Command category changed from `deprecated` to `removed`
This commit is contained in:
committed by
GitHub
parent
0a5f41abc2
commit
435348aa61
46
crates/nu-command/src/removed/format.rs
Normal file
46
crates/nu-command/src/removed/format.rs
Normal file
@ -0,0 +1,46 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SubCommand;
|
||||
|
||||
impl Command for SubCommand {
|
||||
fn name(&self) -> &str {
|
||||
"date format"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("date format")
|
||||
.input_output_types(vec![
|
||||
(Type::Date, Type::String),
|
||||
(Type::String, Type::String),
|
||||
])
|
||||
.allow_variants_without_examples(true) // https://github.com/nushell/nushell/issues/7032
|
||||
.switch("list", "lists strftime cheatsheet", Some('l'))
|
||||
.optional(
|
||||
"format string",
|
||||
SyntaxShape::String,
|
||||
"the desired date format",
|
||||
)
|
||||
.category(Category::Removed)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Removed command: use `format date` instead"
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
_stack: &mut Stack,
|
||||
call: &Call,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
Err(nu_protocol::ShellError::RemovedCommand(
|
||||
self.name().to_string(),
|
||||
"format date".to_owned(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
43
crates/nu-command/src/removed/let_env.rs
Normal file
43
crates/nu-command/src/removed/let_env.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Type};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LetEnv;
|
||||
|
||||
impl Command for LetEnv {
|
||||
fn name(&self) -> &str {
|
||||
"let-env"
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build(self.name())
|
||||
.input_output_types(vec![(Type::Nothing, Type::Nothing)])
|
||||
.allow_variants_without_examples(true)
|
||||
.optional("var_name", SyntaxShape::String, "variable name")
|
||||
.optional(
|
||||
"initial_value",
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||
"equals sign followed by value",
|
||||
)
|
||||
.category(Category::Removed)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"`let-env FOO = ...` has been removed, use `$env.FOO = ...` instead."
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_: &EngineState,
|
||||
_: &mut Stack,
|
||||
call: &Call,
|
||||
_: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
Err(nu_protocol::ShellError::RemovedCommand(
|
||||
self.name().to_string(),
|
||||
"$env.<environment variable> = ...".to_owned(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
7
crates/nu-command/src/removed/mod.rs
Normal file
7
crates/nu-command/src/removed/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
mod format;
|
||||
mod let_env;
|
||||
mod removed_commands;
|
||||
|
||||
pub use format::SubCommand as DateFormat;
|
||||
pub use let_env::LetEnv;
|
||||
pub use removed_commands::*;
|
15
crates/nu-command/src/removed/removed_commands.rs
Normal file
15
crates/nu-command/src/removed/removed_commands.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Return map of <removed_command_name, new_command_name>
|
||||
/// This covers simple removed commands nicely, but it's not great for deprecating
|
||||
/// subcommands like `foo bar` where `foo` is still a valid command.
|
||||
/// For those, it's currently easiest to have a "stub" command that just returns an error.
|
||||
pub fn removed_commands() -> HashMap<String, String> {
|
||||
[
|
||||
("fetch".to_string(), "http get".to_string()),
|
||||
("post".to_string(), "http post".to_string()),
|
||||
("benchmark".to_string(), "timeit".to_string()),
|
||||
]
|
||||
.into_iter()
|
||||
.collect()
|
||||
}
|
Reference in New Issue
Block a user