mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:35:56 +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
@ -374,7 +374,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
|
||||
IsAdmin,
|
||||
};
|
||||
|
||||
// Deprecated
|
||||
// Removed
|
||||
bind_command! {
|
||||
LetEnv,
|
||||
DateFormat,
|
||||
|
@ -3,7 +3,6 @@ mod conversions;
|
||||
mod date;
|
||||
mod debug;
|
||||
mod default_context;
|
||||
mod deprecated;
|
||||
mod env;
|
||||
mod example_test;
|
||||
mod experimental;
|
||||
@ -21,6 +20,7 @@ mod path;
|
||||
mod platform;
|
||||
mod progress_bar;
|
||||
mod random;
|
||||
mod removed;
|
||||
mod shells;
|
||||
mod sort_utils;
|
||||
mod strings;
|
||||
@ -32,7 +32,6 @@ pub use conversions::*;
|
||||
pub use date::*;
|
||||
pub use debug::*;
|
||||
pub use default_context::*;
|
||||
pub use deprecated::*;
|
||||
pub use env::*;
|
||||
#[cfg(test)]
|
||||
pub use example_test::test_examples;
|
||||
@ -50,6 +49,7 @@ pub use network::*;
|
||||
pub use path::*;
|
||||
pub use platform::*;
|
||||
pub use random::*;
|
||||
pub use removed::*;
|
||||
pub use shells::*;
|
||||
pub use sort_utils::*;
|
||||
pub use strings::*;
|
||||
|
@ -23,15 +23,11 @@ impl Command for SubCommand {
|
||||
SyntaxShape::String,
|
||||
"the desired date format",
|
||||
)
|
||||
.category(Category::Date)
|
||||
.category(Category::Removed)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Format a given date using a format string."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec!["fmt", "strftime"]
|
||||
"Removed command: use `format date` instead"
|
||||
}
|
||||
|
||||
fn run(
|
||||
@ -41,7 +37,7 @@ impl Command for SubCommand {
|
||||
call: &Call,
|
||||
_input: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||
Err(nu_protocol::ShellError::RemovedCommand(
|
||||
self.name().to_string(),
|
||||
"format date".to_owned(),
|
||||
call.head,
|
@ -20,11 +20,11 @@ impl Command for LetEnv {
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||
"equals sign followed by value",
|
||||
)
|
||||
.category(Category::Deprecated)
|
||||
.category(Category::Removed)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"`let-env FOO = ...` is deprecated, use `$env.FOO = ...` instead."
|
||||
"`let-env FOO = ...` has been removed, use `$env.FOO = ...` instead."
|
||||
}
|
||||
|
||||
fn run(
|
||||
@ -34,7 +34,7 @@ impl Command for LetEnv {
|
||||
call: &Call,
|
||||
_: PipelineData,
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||
Err(nu_protocol::ShellError::RemovedCommand(
|
||||
self.name().to_string(),
|
||||
"$env.<environment variable> = ...".to_owned(),
|
||||
call.head,
|
@ -1,7 +1,7 @@
|
||||
mod deprecated_commands;
|
||||
mod format;
|
||||
mod let_env;
|
||||
mod removed_commands;
|
||||
|
||||
pub use deprecated_commands::*;
|
||||
pub use format::SubCommand as DateFormat;
|
||||
pub use let_env::LetEnv;
|
||||
pub use removed_commands::*;
|
@ -1,10 +1,10 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Return map of <deprecated_command_name, new_command_name>
|
||||
/// This covers simple deprecated commands nicely, but it's not great for deprecating
|
||||
/// 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 deprecated_commands() -> HashMap<String, String> {
|
||||
pub fn removed_commands() -> HashMap<String, String> {
|
||||
[
|
||||
("fetch".to_string(), "http get".to_string()),
|
||||
("post".to_string(), "http post".to_string()),
|
@ -295,15 +295,15 @@ impl ExternalCommand {
|
||||
match err.kind() {
|
||||
// If file not found, try suggesting alternative commands to the user
|
||||
std::io::ErrorKind::NotFound => {
|
||||
// recommend a replacement if the user tried a deprecated command
|
||||
// recommend a replacement if the user tried a removed command
|
||||
let command_name_lower = self.name.item.to_lowercase();
|
||||
let deprecated = crate::deprecated_commands();
|
||||
if deprecated.contains_key(&command_name_lower) {
|
||||
let replacement = match deprecated.get(&command_name_lower) {
|
||||
let removed_from_nu = crate::removed_commands();
|
||||
if removed_from_nu.contains_key(&command_name_lower) {
|
||||
let replacement = match removed_from_nu.get(&command_name_lower) {
|
||||
Some(s) => s.clone(),
|
||||
None => "".to_string(),
|
||||
};
|
||||
return Err(ShellError::DeprecatedCommand(
|
||||
return Err(ShellError::RemovedCommand(
|
||||
command_name_lower,
|
||||
replacement,
|
||||
self.name.span,
|
||||
|
Reference in New Issue
Block a user