deprecated commands (#4405)
* deprecated commands * deprecated insert command
This commit is contained in:
parent
28947ff9a9
commit
5cf91cb30d
|
@ -343,6 +343,18 @@ pub fn create_default_context(cwd: impl AsRef<Path>) -> EngineState {
|
||||||
ViewSource,
|
ViewSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
|
bind_command! {
|
||||||
|
InsertDeprecated,
|
||||||
|
PivotDeprecated,
|
||||||
|
StrDecimalDeprecated,
|
||||||
|
StrIntDeprecated,
|
||||||
|
NthDeprecated,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "dataframe")]
|
||||||
|
bind_command!(DataframeDeprecated);
|
||||||
|
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
bind_command!(Register);
|
bind_command!(Register);
|
||||||
|
|
||||||
|
|
36
crates/nu-command/src/deprecated/dataframe.rs
Normal file
36
crates/nu-command/src/deprecated/dataframe.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use nu_protocol::{
|
||||||
|
ast::Call,
|
||||||
|
engine::{Command, EngineState, Stack},
|
||||||
|
Category, PipelineData, Signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct DataframeDeprecated;
|
||||||
|
|
||||||
|
impl Command for DataframeDeprecated {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"dataframe"
|
||||||
|
}
|
||||||
|
|
||||||
|
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<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||||
|
self.name().to_string(),
|
||||||
|
"dfr".to_string(),
|
||||||
|
call.head,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
36
crates/nu-command/src/deprecated/insert.rs
Normal file
36
crates/nu-command/src/deprecated/insert.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use nu_protocol::{
|
||||||
|
ast::Call,
|
||||||
|
engine::{Command, EngineState, Stack},
|
||||||
|
Category, PipelineData, Signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct InsertDeprecated;
|
||||||
|
|
||||||
|
impl Command for InsertDeprecated {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"insert"
|
||||||
|
}
|
||||||
|
|
||||||
|
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<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||||
|
self.name().to_string(),
|
||||||
|
"update".to_string(),
|
||||||
|
call.head,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
17
crates/nu-command/src/deprecated/mod.rs
Normal file
17
crates/nu-command/src/deprecated/mod.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
mod insert;
|
||||||
|
mod nth;
|
||||||
|
mod pivot;
|
||||||
|
mod str_decimal;
|
||||||
|
mod str_int;
|
||||||
|
|
||||||
|
pub use insert::InsertDeprecated;
|
||||||
|
pub use nth::NthDeprecated;
|
||||||
|
pub use pivot::PivotDeprecated;
|
||||||
|
pub use str_decimal::StrDecimalDeprecated;
|
||||||
|
pub use str_int::StrIntDeprecated;
|
||||||
|
|
||||||
|
#[cfg(feature = "dataframe")]
|
||||||
|
mod dataframe;
|
||||||
|
|
||||||
|
#[cfg(feature = "dataframe")]
|
||||||
|
pub use dataframe::DataframeDeprecated;
|
36
crates/nu-command/src/deprecated/nth.rs
Normal file
36
crates/nu-command/src/deprecated/nth.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use nu_protocol::{
|
||||||
|
ast::Call,
|
||||||
|
engine::{Command, EngineState, Stack},
|
||||||
|
Category, PipelineData, Signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct NthDeprecated;
|
||||||
|
|
||||||
|
impl Command for NthDeprecated {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"nth"
|
||||||
|
}
|
||||||
|
|
||||||
|
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<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||||
|
self.name().to_string(),
|
||||||
|
"select".to_string(),
|
||||||
|
call.head,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
36
crates/nu-command/src/deprecated/pivot.rs
Normal file
36
crates/nu-command/src/deprecated/pivot.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use nu_protocol::{
|
||||||
|
ast::Call,
|
||||||
|
engine::{Command, EngineState, Stack},
|
||||||
|
Category, PipelineData, Signature,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct PivotDeprecated;
|
||||||
|
|
||||||
|
impl Command for PivotDeprecated {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"pivot"
|
||||||
|
}
|
||||||
|
|
||||||
|
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<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||||
|
self.name().to_string(),
|
||||||
|
"transpose".to_string(),
|
||||||
|
call.head,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
36
crates/nu-command/src/deprecated/str_decimal.rs
Normal file
36
crates/nu-command/src/deprecated/str_decimal.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use nu_protocol::{
|
||||||
|
ast::Call,
|
||||||
|
engine::{Command, EngineState, Stack},
|
||||||
|
Category, PipelineData, 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<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||||
|
self.name().to_string(),
|
||||||
|
"into decimal".to_string(),
|
||||||
|
call.head,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
36
crates/nu-command/src/deprecated/str_int.rs
Normal file
36
crates/nu-command/src/deprecated/str_int.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use nu_protocol::{
|
||||||
|
ast::Call,
|
||||||
|
engine::{Command, EngineState, Stack},
|
||||||
|
Category, PipelineData, 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<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Err(nu_protocol::ShellError::DeprecatedCommand(
|
||||||
|
self.name().to_string(),
|
||||||
|
"into int".to_string(),
|
||||||
|
call.head,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ mod conversions;
|
||||||
mod core_commands;
|
mod core_commands;
|
||||||
mod date;
|
mod date;
|
||||||
mod default_context;
|
mod default_context;
|
||||||
|
mod deprecated;
|
||||||
mod env;
|
mod env;
|
||||||
mod example_test;
|
mod example_test;
|
||||||
mod experimental;
|
mod experimental;
|
||||||
|
@ -24,6 +25,7 @@ pub use conversions::*;
|
||||||
pub use core_commands::*;
|
pub use core_commands::*;
|
||||||
pub use date::*;
|
pub use date::*;
|
||||||
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;
|
||||||
|
|
|
@ -267,6 +267,14 @@ pub enum ShellError {
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
#[diagnostic(help("{1}"))]
|
#[diagnostic(help("{1}"))]
|
||||||
LabeledError(String, String),
|
LabeledError(String, String),
|
||||||
|
|
||||||
|
#[error("Deprecated command {0}")]
|
||||||
|
#[diagnostic(code(nu::shell::deprecated_command), url(docsrs))]
|
||||||
|
DeprecatedCommand(
|
||||||
|
String,
|
||||||
|
String,
|
||||||
|
#[label = "{0} is deprecated. Instead use {1}"] Span,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for ShellError {
|
impl From<std::io::Error> for ShellError {
|
||||||
|
|
|
@ -52,6 +52,7 @@ pub enum Category {
|
||||||
Hash,
|
Hash,
|
||||||
Generators,
|
Generators,
|
||||||
Custom(String),
|
Custom(String),
|
||||||
|
Deprecated,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Category {
|
impl std::fmt::Display for Category {
|
||||||
|
@ -77,6 +78,7 @@ impl std::fmt::Display for Category {
|
||||||
Category::Hash => "hash",
|
Category::Hash => "hash",
|
||||||
Category::Generators => "generators",
|
Category::Generators => "generators",
|
||||||
Category::Custom(name) => name,
|
Category::Custom(name) => name,
|
||||||
|
Category::Deprecated => "deprecated",
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(f, "{}", msg)
|
write!(f, "{}", msg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user