//! CLI type definitions
//!
//! Root CLI structure and Commands enum.
//! Individual command Args are defined in the commands/ module.

use clap::{Parser, Subcommand};
use std::path::PathBuf;

// Import all command Args from commands module
use crate::commands::{
    AddCommand, AuthCommand, BuildArgs, DevArgs, DiagnosticsArgs, FormatArgs, InitArgs, LintArgs, LogsArgs,
    ModelsCommand, NodeArgs, RemoteCommand, RunArgs, SetupArgs, TopicsCommand, TopologyArgs,
};

#[derive(Parser)]
#[command(name = "mecha10")]
#[command(about = "Mecha10 CLI - Build autonomous robots with RL", long_about = None)]
#[command(version)]
pub struct Cli {
    /// Set log level (debug, info, warn, error)
    #[arg(short, long, default_value = "info", global = true)]
    pub log_level: String,

    /// Path to config file
    #[arg(short, long, global = true)]
    pub config: Option<PathBuf>,

    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Add components to the project (nodes, drivers, etc.)
    Add {
        #[command(subcommand)]
        command: AddCommand,
    },

    /// Manage authentication (login, logout, whoami)
    Auth {
        #[command(subcommand)]
        command: AuthCommand,
    },

    /// Build the project
    Build(#[command(flatten)] BuildArgs),

    /// Start development mode with hot-reload
    Dev(#[command(flatten)] DevArgs),

    /// Real-time diagnostics monitoring (streaming, simulation, system resources)
    Diagnostics(#[command(flatten)] DiagnosticsArgs),

    /// Format code
    Format(#[command(flatten)] FormatArgs),

    /// Initialize a new robot project
    Init(#[command(flatten)] InitArgs),

    /// Run linting and code quality checks
    Lint(#[command(flatten)] LintArgs),

    /// View logs from nodes
    Logs(#[command(flatten)] LogsArgs),

    /// AI model management (download, list, remove models from HuggingFace)
    Models {
        #[command(subcommand)]
        command: ModelsCommand,
    },

    /// Run a single node (internal command used by standalone mode)
    #[command(hide = true)]
    Node(#[command(flatten)] NodeArgs),

    /// Manage remote AI nodes running in Docker containers
    Remote {
        #[command(subcommand)]
        command: RemoteCommand,
    },

    /// Run the robot in production mode
    Run(#[command(flatten)] RunArgs),

    /// Run project setup script (installs dependencies)
    Setup(#[command(flatten)] SetupArgs),

    /// Show project status
    Status,

    /// Topic operations - list, watch, monitor, and record topics
    Topics {
        #[command(subcommand)]
        command: TopicsCommand,
    },

    /// Analyze project topology (nodes, pub/sub topics, ports)
    Topology(#[command(flatten)] TopologyArgs),
}
