diff --git a/crates/nu-command/src/core_commands/ignore.rs b/crates/nu-command/src/core_commands/ignore.rs new file mode 100644 index 0000000000..679ec156bb --- /dev/null +++ b/crates/nu-command/src/core_commands/ignore.rs @@ -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 { + Ok(PipelineData::new(call.head)) + } + + fn examples(&self) -> Vec { + 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 {}) + } +} diff --git a/crates/nu-command/src/core_commands/mod.rs b/crates/nu-command/src/core_commands/mod.rs index c15be09e60..0bb930efc4 100644 --- a/crates/nu-command/src/core_commands/mod.rs +++ b/crates/nu-command/src/core_commands/mod.rs @@ -12,6 +12,7 @@ mod help; mod hide; mod history; mod if_; +mod ignore; mod let_; mod metadata; mod module; @@ -33,6 +34,7 @@ pub use help::Help; pub use hide::Hide; pub use history::History; pub use if_::If; +pub use ignore::Ignore; pub use let_::Let; pub use metadata::Metadata; pub use module::Module; diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 33da80fdf1..453486eb22 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -37,6 +37,7 @@ pub fn create_default_context() -> EngineState { Hide, History, If, + Ignore, Let, Metadata, Module,