Implementing Command for Echo, no examples

Referring to:

https://github.com/nushell/nushell/blob/main/crates/nu-command/src/commands/core_commands/echo.rs

as the original implementation.
This commit is contained in:
Antonio Natilla 2021-11-01 09:12:48 +01:00
parent 3176f60b5b
commit f4ed4fa7e3
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,32 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape};
//TODO: add Example
#[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<PipelineData, ShellError> {
Ok(input)
}
//TODO: implement fn examples(&self) -> Vec<Example>
}

View File

@ -1,6 +1,7 @@
mod alias;
mod def;
mod do_;
mod echo;
mod export_def;
mod for_;
mod help;
@ -14,6 +15,7 @@ mod use_;
pub use alias::Alias;
pub use def::Def;
pub use do_::Do;
pub use echo::Echo;
pub use export_def::ExportDef;
pub use for_::For;
pub use help::Help;

View File

@ -30,6 +30,7 @@ pub fn create_default_context() -> EngineState {
Def,
Do,
Each,
Echo,
ExportDef,
External,
For,