//! Arguments for `mcptest coverage`.

use std::path::PathBuf;

use clap::{Args, ValueEnum};

/// Arguments for `mcptest coverage`.
///
/// The command analyzes a suite against a declared tool catalog: which
/// tools, argument combinations, and error fixtures the suite exercises.
/// The catalog comes from a file (a `tools/list` snapshot or a mock
/// manifest) so the check stays deterministic and CI-friendly, the same
/// convention `generate suite` uses.
#[derive(Debug, Args, Default)]
pub struct CoverageArgs {
    /// Path to the suite YAML to analyze. Defaults to `./mcptest.yaml`.
    #[arg(value_name = "SUITE")]
    pub suite: Option<PathBuf>,

    /// Tool catalog the coverage is measured against: a `tools/list` JSON
    /// snapshot (`{"tools": [...]}`), a bare JSON tools array, or a YAML
    /// mock manifest (`mock_server.tools[]`).
    #[arg(long, value_name = "PATH")]
    pub tools_from: Option<PathBuf>,

    /// Emit draft YAML tests for uncovered tools, arguments, and error
    /// paths after the report, ready to merge under the suite's `tools:`
    /// key.
    #[arg(long)]
    pub suggest: bool,

    /// Server key written into suggested drafts. Defaults to the first
    /// server declared in the suite.
    #[arg(long, value_name = "NAME")]
    pub server: Option<String>,

    /// Quality gate threshold as a percentage (0 to 100), applied to tool
    /// coverage.
    ///
    /// When set and the computed tool coverage is below the threshold,
    /// the command exits with code 6.
    #[arg(long, value_name = "PERCENT")]
    pub threshold: Option<f64>,

    /// Output format for the coverage report.
    #[arg(
        long,
        value_enum,
        value_name = "FORMAT",
        default_value_t = CoverageFormat::Pretty
    )]
    pub format: CoverageFormat,
}

/// Output formats accepted by `mcptest coverage --format`.
///
/// Kept as an enum so clap can list the variants in `--help` and reject typos
/// before any analysis starts.
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, ValueEnum)]
#[value(rename_all = "kebab-case")]
pub enum CoverageFormat {
    /// Human-friendly table output (default).
    #[default]
    Pretty,
    /// One JSON object containing the full [`CoverageReport`] (plus a
    /// `suggestions` key under `--suggest`).
    ///
    /// [`CoverageReport`]: mcptest_core::coverage::CoverageReport
    Json,
}
