modcli/commands/
hello.rs

1use crate::command::Command;
2use crate::output::hooks::*;
3
4pub struct HelloCommand;
5
6impl Command for HelloCommand {
7    fn name(&self) -> &'static str {
8        "hello"
9    }
10
11    fn help(&self) -> Option<&str> {
12        Some("Greets the user")
13    }
14
15    fn validate(&self, args: &[String]) -> Result<(), String> {
16        if args.len() > 1 {
17            Err("Hello takes at most one argument (your name).".into())
18        } else {
19            Ok(())
20        }
21    }
22
23    fn execute(&self, args: &[String]) {
24        print_info("CLI started");
25        print_status("Checking mood...");
26        print_success("You seem ready!");
27        print_warn("But don’t get cocky.");
28        print_error("Just kidding. You're good. 😎");
29        if let Some(name) = args.get(0) {
30            println!("Hello, {}!", name);
31        } else {
32            println!("Hello!");
33        }
34    }
35}