forked from extern/nushell
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:
parent
0a5f41abc2
commit
435348aa61
@ -374,7 +374,7 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
|
|||||||
IsAdmin,
|
IsAdmin,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Deprecated
|
// Removed
|
||||||
bind_command! {
|
bind_command! {
|
||||||
LetEnv,
|
LetEnv,
|
||||||
DateFormat,
|
DateFormat,
|
||||||
|
@ -3,7 +3,6 @@ mod conversions;
|
|||||||
mod date;
|
mod date;
|
||||||
mod debug;
|
mod debug;
|
||||||
mod default_context;
|
mod default_context;
|
||||||
mod deprecated;
|
|
||||||
mod env;
|
mod env;
|
||||||
mod example_test;
|
mod example_test;
|
||||||
mod experimental;
|
mod experimental;
|
||||||
@ -21,6 +20,7 @@ mod path;
|
|||||||
mod platform;
|
mod platform;
|
||||||
mod progress_bar;
|
mod progress_bar;
|
||||||
mod random;
|
mod random;
|
||||||
|
mod removed;
|
||||||
mod shells;
|
mod shells;
|
||||||
mod sort_utils;
|
mod sort_utils;
|
||||||
mod strings;
|
mod strings;
|
||||||
@ -32,7 +32,6 @@ pub use conversions::*;
|
|||||||
pub use date::*;
|
pub use date::*;
|
||||||
pub use debug::*;
|
pub use debug::*;
|
||||||
pub use default_context::*;
|
pub use default_context::*;
|
||||||
pub use deprecated::*;
|
|
||||||
pub use env::*;
|
pub use env::*;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub use example_test::test_examples;
|
pub use example_test::test_examples;
|
||||||
@ -50,6 +49,7 @@ pub use network::*;
|
|||||||
pub use path::*;
|
pub use path::*;
|
||||||
pub use platform::*;
|
pub use platform::*;
|
||||||
pub use random::*;
|
pub use random::*;
|
||||||
|
pub use removed::*;
|
||||||
pub use shells::*;
|
pub use shells::*;
|
||||||
pub use sort_utils::*;
|
pub use sort_utils::*;
|
||||||
pub use strings::*;
|
pub use strings::*;
|
||||||
|
@ -23,15 +23,11 @@ impl Command for SubCommand {
|
|||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
"the desired date format",
|
"the desired date format",
|
||||||
)
|
)
|
||||||
.category(Category::Date)
|
.category(Category::Removed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"Format a given date using a format string."
|
"Removed command: use `format date` instead"
|
||||||
}
|
|
||||||
|
|
||||||
fn search_terms(&self) -> Vec<&str> {
|
|
||||||
vec!["fmt", "strftime"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
@ -41,7 +37,7 @@ impl Command for SubCommand {
|
|||||||
call: &Call,
|
call: &Call,
|
||||||
_input: PipelineData,
|
_input: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
Err(nu_protocol::ShellError::DeprecatedCommand(
|
Err(nu_protocol::ShellError::RemovedCommand(
|
||||||
self.name().to_string(),
|
self.name().to_string(),
|
||||||
"format date".to_owned(),
|
"format date".to_owned(),
|
||||||
call.head,
|
call.head,
|
@ -20,11 +20,11 @@ impl Command for LetEnv {
|
|||||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::MathExpression)),
|
||||||
"equals sign followed by value",
|
"equals sign followed by value",
|
||||||
)
|
)
|
||||||
.category(Category::Deprecated)
|
.category(Category::Removed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
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(
|
fn run(
|
||||||
@ -34,7 +34,7 @@ impl Command for LetEnv {
|
|||||||
call: &Call,
|
call: &Call,
|
||||||
_: PipelineData,
|
_: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
Err(nu_protocol::ShellError::DeprecatedCommand(
|
Err(nu_protocol::ShellError::RemovedCommand(
|
||||||
self.name().to_string(),
|
self.name().to_string(),
|
||||||
"$env.<environment variable> = ...".to_owned(),
|
"$env.<environment variable> = ...".to_owned(),
|
||||||
call.head,
|
call.head,
|
@ -1,7 +1,7 @@
|
|||||||
mod deprecated_commands;
|
|
||||||
mod format;
|
mod format;
|
||||||
mod let_env;
|
mod let_env;
|
||||||
|
mod removed_commands;
|
||||||
|
|
||||||
pub use deprecated_commands::*;
|
|
||||||
pub use format::SubCommand as DateFormat;
|
pub use format::SubCommand as DateFormat;
|
||||||
pub use let_env::LetEnv;
|
pub use let_env::LetEnv;
|
||||||
|
pub use removed_commands::*;
|
@ -1,10 +1,10 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// Return map of <deprecated_command_name, new_command_name>
|
/// Return map of <removed_command_name, new_command_name>
|
||||||
/// This covers simple deprecated commands nicely, but it's not great for deprecating
|
/// This covers simple removed commands nicely, but it's not great for deprecating
|
||||||
/// subcommands like `foo bar` where `foo` is still a valid command.
|
/// 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.
|
/// 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()),
|
("fetch".to_string(), "http get".to_string()),
|
||||||
("post".to_string(), "http post".to_string()),
|
("post".to_string(), "http post".to_string()),
|
@ -295,15 +295,15 @@ impl ExternalCommand {
|
|||||||
match err.kind() {
|
match err.kind() {
|
||||||
// If file not found, try suggesting alternative commands to the user
|
// If file not found, try suggesting alternative commands to the user
|
||||||
std::io::ErrorKind::NotFound => {
|
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 command_name_lower = self.name.item.to_lowercase();
|
||||||
let deprecated = crate::deprecated_commands();
|
let removed_from_nu = crate::removed_commands();
|
||||||
if deprecated.contains_key(&command_name_lower) {
|
if removed_from_nu.contains_key(&command_name_lower) {
|
||||||
let replacement = match deprecated.get(&command_name_lower) {
|
let replacement = match removed_from_nu.get(&command_name_lower) {
|
||||||
Some(s) => s.clone(),
|
Some(s) => s.clone(),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
return Err(ShellError::DeprecatedCommand(
|
return Err(ShellError::RemovedCommand(
|
||||||
command_name_lower,
|
command_name_lower,
|
||||||
replacement,
|
replacement,
|
||||||
self.name.span,
|
self.name.span,
|
||||||
|
@ -65,8 +65,8 @@ fn commands_declare_input_output_types() {
|
|||||||
let sig_name = cmd.signature().name;
|
let sig_name = cmd.signature().name;
|
||||||
let category = cmd.signature().category;
|
let category = cmd.signature().category;
|
||||||
|
|
||||||
if matches!(category, Category::Deprecated | Category::Custom(_)) {
|
if matches!(category, Category::Removed | Category::Custom(_)) {
|
||||||
// Deprecated commands don't have to conform
|
// Deprecated/Removed commands don't have to conform
|
||||||
// TODO: also upgrade the `--features dataframe` commands
|
// TODO: also upgrade the `--features dataframe` commands
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
ast::Call,
|
ast::Call,
|
||||||
engine::{EngineState, Stack},
|
engine::{EngineState, Stack},
|
||||||
Example, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Value,
|
Category, Example, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Value,
|
||||||
};
|
};
|
||||||
use std::{collections::HashMap, fmt::Write};
|
use std::{collections::HashMap, fmt::Write};
|
||||||
|
|
||||||
@ -94,8 +94,8 @@ fn get_documentation(
|
|||||||
let signatures = engine_state.get_signatures(true);
|
let signatures = engine_state.get_signatures(true);
|
||||||
for sig in signatures {
|
for sig in signatures {
|
||||||
if sig.name.starts_with(&format!("{cmd_name} "))
|
if sig.name.starts_with(&format!("{cmd_name} "))
|
||||||
// Don't display deprecated commands in the Subcommands list
|
// Don't display removed/deprecated commands in the Subcommands list
|
||||||
&& !sig.usage.starts_with("Deprecated command")
|
&& !matches!(sig.category, Category::Removed)
|
||||||
{
|
{
|
||||||
subcommands.push(format!(" {C}{}{RESET} - {}", sig.name, sig.usage));
|
subcommands.push(format!(" {C}{}{RESET} - {}", sig.name, sig.usage));
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ impl EngineState {
|
|||||||
for decl in &overlay_frame.decls {
|
for decl in &overlay_frame.decls {
|
||||||
if overlay_frame.visibility.is_decl_id_visible(decl.1) && predicate(decl.0) {
|
if overlay_frame.visibility.is_decl_id_visible(decl.1) && predicate(decl.0) {
|
||||||
let command = self.get_decl(*decl.1);
|
let command = self.get_decl(*decl.1);
|
||||||
if ignore_deprecated && command.signature().category == Category::Deprecated {
|
if ignore_deprecated && command.signature().category == Category::Removed {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
output.push((decl.0.clone(), Some(command.usage().to_string())));
|
output.push((decl.0.clone(), Some(command.usage().to_string())));
|
||||||
@ -1713,8 +1713,7 @@ impl<'a> StateWorkingSet<'a> {
|
|||||||
for decl in &overlay_frame.decls {
|
for decl in &overlay_frame.decls {
|
||||||
if overlay_frame.visibility.is_decl_id_visible(decl.1) && predicate(decl.0) {
|
if overlay_frame.visibility.is_decl_id_visible(decl.1) && predicate(decl.0) {
|
||||||
let command = self.get_decl(*decl.1);
|
let command = self.get_decl(*decl.1);
|
||||||
if ignore_deprecated && command.signature().category == Category::Deprecated
|
if ignore_deprecated && command.signature().category == Category::Removed {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
output.push((decl.0.clone(), Some(command.usage().to_string())));
|
output.push((decl.0.clone(), Some(command.usage().to_string())));
|
||||||
|
@ -982,30 +982,17 @@ pub enum ShellError {
|
|||||||
#[diagnostic()]
|
#[diagnostic()]
|
||||||
OutsideSpannedLabeledError(#[source_code] String, String, String, #[label("{2}")] Span),
|
OutsideSpannedLabeledError(#[source_code] String, String, String, #[label("{2}")] Span),
|
||||||
|
|
||||||
/// Attempted to use a deprecated command.
|
/// Attempted to use a command that has been removed from Nushell.
|
||||||
///
|
///
|
||||||
/// ## Resolution
|
/// ## Resolution
|
||||||
///
|
///
|
||||||
/// Check the help for the new suggested command and update your script accordingly.
|
/// Check the help for the new suggested command and update your script accordingly.
|
||||||
#[error("Deprecated command {0}")]
|
#[error("Removed command: {0}")]
|
||||||
#[diagnostic(code(nu::shell::deprecated_command))]
|
#[diagnostic(code(nu::shell::removed_command))]
|
||||||
DeprecatedCommand(
|
RemovedCommand(
|
||||||
String,
|
String,
|
||||||
String,
|
String,
|
||||||
#[label = "'{0}' is deprecated. Please use '{1}' instead."] Span,
|
#[label = "'{0}' has been removed from Nushell. Please use '{1}' instead."] Span,
|
||||||
),
|
|
||||||
|
|
||||||
/// Attempted to use a deprecated parameter.
|
|
||||||
///
|
|
||||||
/// ## Resolution
|
|
||||||
///
|
|
||||||
/// Check the help for the command and update your script accordingly.
|
|
||||||
#[error("Deprecated parameter {0}")]
|
|
||||||
#[diagnostic(code(nu::shell::deprecated_command))]
|
|
||||||
DeprecatedParameter(
|
|
||||||
String,
|
|
||||||
String,
|
|
||||||
#[label = "Parameter '{0}' is deprecated. Please use '{1}' instead."] Span,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
/// Non-Unicode input received.
|
/// Non-Unicode input received.
|
||||||
|
@ -49,7 +49,7 @@ pub enum Category {
|
|||||||
Date,
|
Date,
|
||||||
Debug,
|
Debug,
|
||||||
Default,
|
Default,
|
||||||
Deprecated,
|
Removed,
|
||||||
Env,
|
Env,
|
||||||
Experimental,
|
Experimental,
|
||||||
FileSystem,
|
FileSystem,
|
||||||
@ -81,7 +81,7 @@ impl std::fmt::Display for Category {
|
|||||||
Category::Date => "date",
|
Category::Date => "date",
|
||||||
Category::Debug => "debug",
|
Category::Debug => "debug",
|
||||||
Category::Default => "default",
|
Category::Default => "default",
|
||||||
Category::Deprecated => "deprecated",
|
Category::Removed => "removed",
|
||||||
Category::Env => "env",
|
Category::Env => "env",
|
||||||
Category::Experimental => "experimental",
|
Category::Experimental => "experimental",
|
||||||
Category::FileSystem => "filesystem",
|
Category::FileSystem => "filesystem",
|
||||||
|
Loading…
Reference in New Issue
Block a user