modcli/commands/
ping.rs

1use crate::command::Command;
2use crate::error::ModCliError;
3
4pub struct PingCommand;
5
6impl Command for PingCommand {
7    fn name(&self) -> &'static str {
8        "ping"
9    }
10
11    fn help(&self) -> Option<&str> {
12        Some("Responds with pong")
13    }
14
15    fn validate(&self, args: &[String]) -> Result<(), ModCliError> {
16        if !args.is_empty() {
17            Err(ModCliError::InvalidUsage(
18                "Ping does not accept any arguments.".into(),
19            ))
20        } else {
21            Ok(())
22        }
23    }
24
25    fn execute(&self, _args: &[String]) {
26        println!("Pong!");
27    }
28}