//! Arguments for `mcptest schema-lint`.

use std::path::PathBuf;

use clap::{Args, ValueEnum};

/// Lint the input schemas in a saved `tools/list` snapshot (WOR-1241).
///
/// An under-constrained `inputSchema` lets malformed input through to the
/// server. These rules catch that statically, before a fuzz sweep finds it at
/// runtime, and each finding carries a stable `SCH-NNN` id. The `--fix` autofix
/// adds the mechanical constraints (`additionalProperties: false` and a
/// `required` listing every declared property); it never invents a type.
///
/// Distinct from `mcptest lint`, which scans suites for deprecated MCP features.
#[derive(Debug, Args, Default)]
pub struct SchemaLintArgs {
    /// Path to a `tools/list` snapshot JSON file (an object with a `tools`
    /// array, as written by `mcptest diff` snapshots or `tools/list` capture).
    #[arg(value_name = "SNAPSHOT")]
    pub snapshot: PathBuf,

    /// Output format for the findings report (ignored with `--fix`, which
    /// emits the tightened catalog instead).
    #[arg(long, value_enum, value_name = "FORMAT", default_value_t = SchemaLintFormat::Pretty)]
    pub format: SchemaLintFormat,

    /// Apply the autofix: emit the tightened catalog (every tool's
    /// `inputSchema` with the mechanical constraints added) instead of a
    /// findings report. Prints to stdout unless `--write` is also set.
    #[arg(long)]
    pub fix: bool,

    /// With `--fix`, rewrite the snapshot file in place instead of printing the
    /// tightened catalog. No effect without `--fix`.
    #[arg(long, requires = "fix")]
    pub write: bool,

    /// Treat findings as non-failure. The command always exits 0 when set
    /// (default is to exit 1 if any finding lands).
    #[arg(long)]
    pub no_fail: bool,
}

/// Output format for `mcptest schema-lint`.
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, ValueEnum)]
pub enum SchemaLintFormat {
    /// Human-readable list grouped by tool.
    #[default]
    Pretty,
    /// Newline-delimited JSON per finding, plus a final `summary` line.
    Json,
}
