//! Handler for `mcptest model-compat <subcommand>`.

use anyhow::Result;

use crate::cli::args::{ModelCompatArgs, ModelCompatCommand, ModelCompatDiffFormatCli};
use crate::commands;

/// Handle `mcptest model-compat <subcommand>`.
///
/// Single match arm that translates the clap-derived args into the
/// plain-data structs `commands::model_compat` consumes and dispatches.
pub(crate) fn model_compat_command(args: ModelCompatArgs) -> Result<i32> {
    match args.command {
        ModelCompatCommand::Capture(c) => {
            commands::run_model_compat_capture(commands::ModelCompatCaptureRunArgs {
                model: c.model,
                output: c.output,
                filter: c.filter,
                input: c.input,
                config: c.config,
            })
        }
        ModelCompatCommand::Diff(d) => {
            let format = match d.format {
                ModelCompatDiffFormatCli::Pretty => commands::ModelCompatDiffFormat::Pretty,
                ModelCompatDiffFormatCli::Json => commands::ModelCompatDiffFormat::Json,
            };
            commands::run_model_compat_diff(commands::ModelCompatDiffRunArgs {
                baseline: d.baseline,
                candidate: d.candidate,
                format,
                filter: d.filter,
            })
        }
        ModelCompatCommand::Run(r) => {
            commands::run_model_compat_run(commands::ModelCompatRunRunArgs {
                baseline: r.baseline,
                model: r.model,
                candidate: r.candidate,
            })
        }
    }
}
