use cli_command::cli_match;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("đ§ Simple CLI Match Macro Demo");
println!();
cli_match! {
"hello" => {
println!("đ Hello! Welcome to the cli_match! macro demo!");
Ok(())
},
"goodbye" => {
println!("đ Goodbye! Thanks for trying the cli_match! macro!");
Ok(())
},
"info" => {
println!("âšī¸ This is the info command!");
println!(" The cli_match! macro automatically handles command parsing.");
Ok(())
},
"help" | "--help" | "-h" => {
print_help();
Ok(())
},
_ => {
eprintln!("â Unknown command: {}", std::env::args().nth(1).unwrap_or_else(|| "none".to_string()));
print_help();
Ok(())
}
}
}
fn print_help() {
println!("đ§ Simple CLI Match Example");
println!();
println!("This example demonstrates the cli_match! macro for command routing.");
println!("The macro automatically parses the command line and matches against command names.");
println!();
println!("Usage:");
println!(" simple_cli_match <COMMAND>");
println!();
println!("Commands:");
println!(" hello Say hello");
println!(" goodbye Say goodbye");
println!(" info Show information about the macro");
println!(" help Show this help message");
println!();
println!("Examples:");
println!(" cargo run --example simple_cli_match -- hello");
println!(" cargo run --example simple_cli_match -- info");
println!(" cargo run --example simple_cli_match -- help");
println!();
println!("đ Notice how cli_match! eliminates the need to manually parse command line!");
println!(" Compare this to the traditional approach:");
println!(" let cmd = parse_command_line()?;");
println!(" match cmd.name.as_str() {{ ... }}");
}