mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
add keep deprecated commands (#5124)
This commit is contained in:
parent
4f974efeba
commit
bdfad6b1de
5 changed files with 117 additions and 0 deletions
|
@ -371,6 +371,9 @@ pub fn create_default_context(cwd: impl AsRef<Path>) -> EngineState {
|
|||
NthDeprecated,
|
||||
UnaliasDeprecated,
|
||||
StrFindReplaceDeprecated,
|
||||
KeepDeprecated,
|
||||
KeepUntilDeprecated,
|
||||
KeepWhileDeprecated,
|
||||
};
|
||||
|
||||
#[cfg(feature = "dataframe")]
|
||||
|
|
36
crates/nu-command/src/deprecated/keep_.rs
Normal file
36
crates/nu-command/src/deprecated/keep_.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, PipelineData, Signature,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct KeepDeprecated;
|
||||
|
||||
impl Command for KeepDeprecated {
|
||||
fn name(&self) -> &str {
|
||||
"keep"
|
||||
}
|
||||
|
||||
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(),
|
||||
"take".to_string(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
36
crates/nu-command/src/deprecated/keep_until.rs
Normal file
36
crates/nu-command/src/deprecated/keep_until.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, PipelineData, Signature,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct KeepUntilDeprecated;
|
||||
|
||||
impl Command for KeepUntilDeprecated {
|
||||
fn name(&self) -> &str {
|
||||
"keep until"
|
||||
}
|
||||
|
||||
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(),
|
||||
"take until".to_string(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
36
crates/nu-command/src/deprecated/keep_while.rs
Normal file
36
crates/nu-command/src/deprecated/keep_while.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
Category, PipelineData, Signature,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct KeepWhileDeprecated;
|
||||
|
||||
impl Command for KeepWhileDeprecated {
|
||||
fn name(&self) -> &str {
|
||||
"keep while"
|
||||
}
|
||||
|
||||
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(),
|
||||
"take while".to_string(),
|
||||
call.head,
|
||||
))
|
||||
}
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
mod keep_;
|
||||
mod keep_until;
|
||||
mod keep_while;
|
||||
mod match_;
|
||||
mod nth;
|
||||
mod pivot;
|
||||
|
@ -7,6 +10,9 @@ mod str_find_replace;
|
|||
mod str_int;
|
||||
mod unalias;
|
||||
|
||||
pub use keep_::KeepDeprecated;
|
||||
pub use keep_until::KeepUntilDeprecated;
|
||||
pub use keep_while::KeepWhileDeprecated;
|
||||
pub use match_::MatchDeprecated;
|
||||
pub use nth::NthDeprecated;
|
||||
pub use pivot::PivotDeprecated;
|
||||
|
|
Loading…
Reference in a new issue