forked from extern/nushell
Ported ignore
command to engine-q (#621)
* Ported `ignore` command to engine-q * Format ignore command
This commit is contained in:
parent
80649f2341
commit
56ae07adb9
48
crates/nu-command/src/core_commands/ignore.rs
Normal file
48
crates/nu-command/src/core_commands/ignore.rs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
use nu_protocol::ast::Call;
|
||||||
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
|
use nu_protocol::{Category, Example, PipelineData, Signature};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Ignore;
|
||||||
|
|
||||||
|
impl Command for Ignore {
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
"ignore"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(&self) -> &str {
|
||||||
|
"Ignore the output of the previous command in the pipeline"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn signature(&self) -> nu_protocol::Signature {
|
||||||
|
Signature::build("ignore").category(Category::Core)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(
|
||||||
|
&self,
|
||||||
|
_engine_state: &EngineState,
|
||||||
|
_stack: &mut Stack,
|
||||||
|
call: &Call,
|
||||||
|
_input: PipelineData,
|
||||||
|
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||||
|
Ok(PipelineData::new(call.head))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
vec![Example {
|
||||||
|
description: "Ignore the output of an echo command",
|
||||||
|
example: "echo done | ignore",
|
||||||
|
result: None,
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
#[test]
|
||||||
|
fn test_examples() {
|
||||||
|
use super::Ignore;
|
||||||
|
use crate::test_examples;
|
||||||
|
test_examples(Ignore {})
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ mod help;
|
|||||||
mod hide;
|
mod hide;
|
||||||
mod history;
|
mod history;
|
||||||
mod if_;
|
mod if_;
|
||||||
|
mod ignore;
|
||||||
mod let_;
|
mod let_;
|
||||||
mod metadata;
|
mod metadata;
|
||||||
mod module;
|
mod module;
|
||||||
@ -33,6 +34,7 @@ pub use help::Help;
|
|||||||
pub use hide::Hide;
|
pub use hide::Hide;
|
||||||
pub use history::History;
|
pub use history::History;
|
||||||
pub use if_::If;
|
pub use if_::If;
|
||||||
|
pub use ignore::Ignore;
|
||||||
pub use let_::Let;
|
pub use let_::Let;
|
||||||
pub use metadata::Metadata;
|
pub use metadata::Metadata;
|
||||||
pub use module::Module;
|
pub use module::Module;
|
||||||
|
@ -37,6 +37,7 @@ pub fn create_default_context() -> EngineState {
|
|||||||
Hide,
|
Hide,
|
||||||
History,
|
History,
|
||||||
If,
|
If,
|
||||||
|
Ignore,
|
||||||
Let,
|
Let,
|
||||||
Metadata,
|
Metadata,
|
||||||
Module,
|
Module,
|
||||||
|
Loading…
Reference in New Issue
Block a user