//! Arguments for `mcptest discover`.

use std::path::PathBuf;

use clap::Args;

/// Arguments for `mcptest discover`.
///
/// `server` is either a bare URL or a `name=url` pair. The scaffolder
/// writes `tests.yaml` by default; pass `--output` to land it elsewhere.
/// Passing `--url <base>` switches to the well-known discovery mode
/// added + : fetch `.well-known/mcp.json`, print the
/// resulting `server:` YAML block (or merge it into `mcptest.local.yml`
/// when `--write` is supplied), and exit.
#[derive(Debug, Args)]
pub struct DiscoverArgs {
    /// MCP server endpoint. Accepts `https://...` or `name=https://...`.
    /// Optional when `--url` is supplied.
    pub server: Option<String>,

    /// Path for the scaffolded suite. Defaults to `tests.yaml` in the
    /// current directory.
    #[arg(long, value_name = "PATH", default_value = "tests.yaml")]
    pub output: PathBuf,

    /// Read a bearer token from this env var and send it as
    /// `Authorization: Bearer <value>` during the probe.
    #[arg(long = "bearer-token-env", value_name = "NAME")]
    pub bearer_token_env: Option<String>,

    /// Base URL whose `.well-known/mcp.json` should be fetched.
    ///
    /// When set, `mcptest discover` skips the streamable HTTP probe and
    /// renders the parsed `server:` YAML block. Mutually exclusive with
    /// the positional `server` argument: pick one entry point.
    #[arg(long = "url", value_name = "BASE")]
    pub url: Option<String>,

    /// Write the well-known YAML into this path instead of stdout. Only
    /// honored together with `--url`.
    #[arg(long = "write", value_name = "PATH")]
    pub write: Option<PathBuf>,

    /// Infer a static tool dependency graph from the probed `tools/list`
    /// catalog and print it as Mermaid plus a text table, instead of
    /// scaffolding a suite. Offline analysis: no extra network calls beyond
    /// the one probe. Ignored together with `--url`.
    #[arg(long = "graph")]
    pub graph: bool,
}
