1use std::fmt::Debug;
2use std::marker::PhantomData;
3
4use super::BaseCommand;
5use crate::error::ShiError;
6use crate::Result;
7
8#[derive(Debug)]
9pub struct EchoCommand<S> {
15 phantom: PhantomData<S>,
16}
17
18impl<S> Default for EchoCommand<S> {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl<S> EchoCommand<S> {
25 pub fn new() -> EchoCommand<S> {
27 EchoCommand {
28 phantom: PhantomData,
29 }
30 }
31}
32
33impl<S> BaseCommand for EchoCommand<S> {
34 type State = S;
35
36 fn name(&self) -> &str {
37 "echo"
38 }
39
40 fn validate_args(&self, args: &[String]) -> Result<()> {
41 if args.is_empty() {
42 return Err(ShiError::NoArgs);
43 }
44
45 Ok(())
46 }
47
48 fn execute(&self, _: &mut S, args: &[String]) -> Result<String> {
49 Ok(format!("ECHO: '{:?}'", args))
52 }
53}