mod-cli 0.6.4

A fully customizable, feature-rich CLI framework for Rust. Define commands, prefixes, styled output, and more—built for flexibility and speed.
Documentation
use crate::command::Command;
use crate::error::ModCliError;

pub struct PingCommand;

impl Command for PingCommand {
    fn name(&self) -> &'static str {
        "ping"
    }

    fn help(&self) -> Option<&str> {
        Some("Responds with pong")
    }

    fn validate(&self, args: &[String]) -> Result<(), ModCliError> {
        if !args.is_empty() {
            Err(ModCliError::InvalidUsage(
                "Ping does not accept any arguments.".into(),
            ))
        } else {
            Ok(())
        }
    }

    fn execute(&self, _args: &[String]) {
        println!("Pong!");
    }
}