mirror of
https://github.com/nushell/nushell.git
synced 2025-04-24 21:28:20 +02:00
Adding examples and test for Echo
This commit is contained in:
parent
f4ed4fa7e3
commit
89225cf55c
@ -1,7 +1,6 @@
|
|||||||
use nu_protocol::ast::Call;
|
use nu_protocol::ast::Call;
|
||||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape};
|
use nu_protocol::{Example, PipelineData, ShellError, Signature, SyntaxShape, Value};
|
||||||
//TODO: add Example
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Echo;
|
pub struct Echo;
|
||||||
@ -28,5 +27,29 @@ impl Command for Echo {
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
Ok(input)
|
Ok(input)
|
||||||
}
|
}
|
||||||
//TODO: implement fn examples(&self) -> Vec<Example>
|
|
||||||
|
fn examples(&self) -> Vec<Example> {
|
||||||
|
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 {})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user