1
0
mirror of https://github.com/nushell/nushell.git synced 2025-01-23 23:00:01 +01:00

Ported ignore command to engine-q ()

* Ported `ignore` command to engine-q

* Format ignore command
This commit is contained in:
Justin 2021-12-30 12:54:33 +08:00 committed by GitHub
parent 80649f2341
commit 56ae07adb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 0 deletions
crates/nu-command/src

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

View File

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

View File

@ -37,6 +37,7 @@ pub fn create_default_context() -> EngineState {
Hide,
History,
If,
Ignore,
Let,
Metadata,
Module,