//! CLI snapshot gate (plan §3.3, §11): the existing terminal commands' `--help`
//! output is frozen. If this test fails, the terminal interface changed — which
//! is a regression unless deliberate, in which case regenerate the snapshot in
//! `tests/snapshots/<cmd>.txt`. New subcommands (`mcp`/`serve`) are additive and
//! intentionally not snapshotted here.

use std::process::Command;

const COMMANDS: &[&str] = &[
    "init",
    "update",
    "ask",
    "lint",
    "status",
    "config",
    "providers",
    "login",
];

#[test]
fn existing_command_help_is_frozen() {
    let bin = env!("CARGO_BIN_EXE_hephaes");
    for cmd in COMMANDS {
        let out = Command::new(bin)
            .args([cmd, "--help"])
            .output()
            .expect("run hephaes");
        assert!(out.status.success(), "`{cmd} --help` exited non-zero");
        let got = String::from_utf8_lossy(&out.stdout);
        let path = format!("{}/tests/snapshots/{cmd}.txt", env!("CARGO_MANIFEST_DIR"));
        let want =
            std::fs::read_to_string(&path).unwrap_or_else(|_| panic!("missing snapshot {path}"));
        assert_eq!(
            got, want,
            "CLI help for `{cmd}` changed — the terminal interface is frozen. \
             If this is intentional, update tests/snapshots/{cmd}.txt"
        );
    }
}
