use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{Example, PipelineData, ShellError, Signature, SyntaxShape, Value}; #[derive(Clone)] pub struct Echo; impl Command for Echo { fn name(&self) -> &str { "echo" } fn usage(&self) -> &str { "Echo the arguments back to the user." } fn signature(&self) -> Signature { Signature::build("echo").rest("rest", SyntaxShape::Any, "the values to echo") } fn run( &self, _engine_state: &EngineState, _stack: &mut Stack, _call: &Call, input: PipelineData, ) -> Result { Ok(input) } fn examples(&self) -> Vec { vec![ Example { description: "Put a hello message in the pipeline", example: "echo 'hello'", result: Some(Value::test_string("hello")), }, Example { description: "Print the value of the special '$nu' variable", example: "echo $nu", result: None, }, ] } } #[cfg(test)] mod test { #[test] fn test_examples() { use super::Echo; use crate::test_examples; test_examples(Echo {}) } }