add keep deprecated commands (#5124)

This commit is contained in:
Darren Schroeder 2022-04-07 17:10:46 -05:00 committed by GitHub
parent 4f974efeba
commit bdfad6b1de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 117 additions and 0 deletions

View file

@ -371,6 +371,9 @@ pub fn create_default_context(cwd: impl AsRef<Path>) -> EngineState {
NthDeprecated,
UnaliasDeprecated,
StrFindReplaceDeprecated,
KeepDeprecated,
KeepUntilDeprecated,
KeepWhileDeprecated,
};
#[cfg(feature = "dataframe")]

View 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,
))
}
}

View 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,
))
}
}

View 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,
))
}
}

View file

@ -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;