modcli/commands/echo.rs
1use crate::command::Command;
2
3pub struct EchoCommand;
4
5impl Command for EchoCommand {
6 fn name(&self) -> &'static str {
7 "echo"
8 }
9
10 fn help(&self) -> Option<&str> {
11 Some("Repeats your input")
12 }
13
14 fn validate(&self, args: &[String]) -> Result<(), String> {
15 if args.is_empty() {
16 Err("You must provide at least one word to echo.".into())
17 } else {
18 Ok(())
19 }
20 }
21
22 fn execute(&self, args: &[String]) {
23 println!("{}", args.join(" "));
24 }
25}