modcli/commands/
hello.rs

1use crate::command::Command;
2use crate::output::hook;
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        hook::info("CLI started");
25        hook::status("Checking mood...");
26        hook::success("You seem ready!");
27        hook::warn("But don’t get cocky.");
28        hook::error("Just kidding. You're good. 😎");
29        hook::unknown("Unknown command. Try 'help'.");
30        hook::deprecated("This command is deprecated.");
31        if let Some(name) = args.get(0) {
32            println!("Hello, {}!", name);
33        } else {
34            println!("Hello!");
35        }
36    }
37}