//! CLI argument parsing and subcommand dispatch.
//!
//! Uses clap for CLI definitions.

use clap::{Parser, Subcommand};

/// TUI tool for managing multiple Claude Code sessions in parallel
#[derive(Parser, Debug)]
#[command(name = "tazuna", version, about)]
pub struct Cli {
    /// Subcommand to run
    #[command(subcommand)]
    pub command: Option<Commands>,
}

/// Available subcommands
#[derive(Subcommand, Debug)]
pub enum Commands {
    /// Receive hook event from Claude Code (internal use)
    ///
    /// This subcommand is called by Claude Code hooks via settings.json.
    /// It reads the hook event JSON from stdin and forwards it to the
    /// main tazuna process via Unix socket.
    Notify,
}

#[cfg(test)]
mod tests {
    use super::*;
    use clap::CommandFactory;

    #[test]
    fn cli_parses_no_args() {
        let cli = Cli::parse_from::<_, &str>([]);
        assert!(cli.command.is_none());
    }

    #[test]
    fn cli_parses_notify() {
        let cli = Cli::parse_from(["tazuna", "notify"]);
        assert!(matches!(cli.command, Some(Commands::Notify)));
    }

    #[test]
    fn cli_help_works() {
        // Just verify it doesn't panic
        Cli::command().debug_assert();
    }
}
