cli-command 0.1.0

A lightweight and ergonomic command-line argument parser for Rust
Documentation
//! A simple example demonstrating the cli_match! macro.
//!
//! This example shows how the cli_match! macro can simplify command routing
//! by automatically parsing the command line and matching against command names.

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() {{ ... }}");
}