//! Arguments for `mcptest model-compat`.

use std::path::PathBuf;

use clap::{Args, Subcommand, ValueEnum};

/// Arguments for `mcptest model-compat`.
///
/// Three subcommands ride underneath: `capture` writes a baseline,
/// `diff` compares two baselines, and `run` ties them together by
/// re-running the suite against a candidate model and diffing the
/// result against a saved baseline.
#[derive(Debug, Args)]
pub struct ModelCompatArgs {
    /// Which model-compat operation to run.
    #[command(subcommand)]
    pub command: ModelCompatCommand,
}

/// Subcommands for `mcptest model-compat`.
#[derive(Debug, Subcommand)]
pub enum ModelCompatCommand {
    /// Capture a baseline snapshot for the given model.
    Capture(ModelCompatCaptureArgs),
    /// Diff two saved baselines.
    Diff(ModelCompatDiffArgs),
    /// Re-run the suite against a candidate and diff against the baseline.
    Run(ModelCompatRunArgs),
}

/// Arguments for `mcptest model-compat capture`.
#[derive(Debug, Args)]
pub struct ModelCompatCaptureArgs {
    /// Provider-qualified model identifier (for example
    /// `anthropic:claude-sonnet-4.5`).
    #[arg(long, value_name = "ID")]
    pub model: String,
    /// Path to write the baseline JSON to.
    #[arg(long, value_name = "PATH")]
    pub output: PathBuf,
    /// Optional glob narrowing the captured assertion list.
    #[arg(long, value_name = "GLOB")]
    pub filter: Option<String>,
    /// Pre-built baseline file to ride on instead of capturing live. Takes
    /// precedence over `--config`. Useful for tests and for re-stamping an
    /// existing baseline under a different model id.
    #[arg(long, value_name = "PATH")]
    pub input: Option<PathBuf>,
    /// Suite to capture live (WOR-1385): each `agents:` entry is driven
    /// against a provider resolved for `--model`, and the resulting
    /// exchanges are written as the baseline. Used when `--input` is absent.
    #[arg(long, value_name = "PATH")]
    pub config: Option<PathBuf>,
}

/// Arguments for `mcptest model-compat diff`.
#[derive(Debug, Args)]
pub struct ModelCompatDiffArgs {
    /// Path to the baseline file (left-hand side).
    pub baseline: PathBuf,
    /// Path to the candidate file (right-hand side).
    pub candidate: PathBuf,
    /// Output format.
    #[arg(
        long,
        value_enum,
        value_name = "FORMAT",
        default_value_t = ModelCompatDiffFormatCli::Pretty
    )]
    pub format: ModelCompatDiffFormatCli,
    /// Optional glob narrowing which assertion ids appear in the diff.
    #[arg(long, value_name = "GLOB")]
    pub filter: Option<String>,
}

/// Arguments for `mcptest model-compat run`.
#[derive(Debug, Args)]
pub struct ModelCompatRunArgs {
    /// Path to the baseline file.
    #[arg(long, value_name = "PATH")]
    pub baseline: PathBuf,
    /// Provider-qualified candidate model identifier. Stored in the
    /// printed report so the operator sees which model produced the
    /// candidate.
    #[arg(long, value_name = "ID")]
    pub model: String,
    /// Path to the candidate baseline. The live runner lands in a
    /// follow-up ticket; for v1.1 this flag lets `run` ride on a
    /// pre-captured candidate so PASS/DRIFT/FAIL exit handling is
    /// exercised end to end.
    #[arg(long, value_name = "PATH")]
    pub candidate: PathBuf,
}

/// Output format accepted by `mcptest model-compat diff --format`.
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum ModelCompatDiffFormatCli {
    /// Color-tinted plain text (default).
    #[default]
    Pretty,
    /// Pretty-printed JSON of the `BaselineDiff`.
    Json,
}
