use clap::Parser;
use crate::explain::Format;
use crate::pattern;
use crate::pulse::HeartbeatOpts;
#[derive(Parser, Debug)]
#[command(
name = "ct-test",
version,
about = "Run a command as a framed experiment and emit a templated SUCCESS/ERROR verdict.",
long_about = "ct-test frames a command with the question it answers, classifies the result from \
what the command prints (not only its exit code), and emits a templated verdict \
(also reachable as `ct test`). The command is always launched directly — there is \
no shell mode. See `ct-test --explain` for agent-oriented documentation."
)]
pub struct Cli {
#[arg(long)]
pub question: Option<String>,
#[arg(long)]
pub cmd: Option<String>,
#[arg(long)]
pub stdin: Option<String>,
#[arg(long, value_enum)]
pub mode: Option<pattern::Mode>,
#[arg(long, value_name = "SECS")]
pub timeout: Option<f64>,
#[command(flatten)]
pub heartbeat: HeartbeatOpts,
#[arg(long)]
pub err_match: Option<String>,
#[arg(long)]
pub err_match_stdout: Option<String>,
#[arg(long)]
pub err_match_stderr: Option<String>,
#[arg(long)]
pub ok_match: Option<String>,
#[arg(long)]
pub ok_match_stdout: Option<String>,
#[arg(long)]
pub ok_match_stderr: Option<String>,
#[arg(long, value_enum)]
pub otherwise: Option<Otherwise>,
#[arg(long)]
pub focus: Option<String>,
#[arg(long, default_value_t = 2)]
pub context: usize,
#[arg(long, value_name = "N")]
pub capture_tail: Option<usize>,
#[arg(long, alias = "emit-stdout")]
pub emit: Option<String>,
#[arg(long)]
pub emit_stderr: Option<String>,
#[arg(long)]
pub show_output: bool,
#[arg(long)]
pub quiet: bool,
#[arg(long, value_enum, num_args = 0..=1, default_missing_value = "md")]
pub explain: Option<Format>,
#[arg(last = true)]
pub args: Vec<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum Otherwise {
Success,
Error,
Exit,
}
impl Otherwise {
pub fn label(self) -> &'static str {
match self {
Otherwise::Success => "success",
Otherwise::Error => "error",
Otherwise::Exit => "exit",
}
}
}