1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Gate command parser types.
//!
//! This module owns the clap/serde contract for `tokmd gate` while the parent
//! parser module keeps the top-level command dispatch shape.
use std::path::PathBuf;
use clap::{Args, ValueEnum};
use serde::{Deserialize, Serialize};
use super::AnalysisPreset;
#[derive(Args, Debug, Clone)]
pub struct CliGateArgs {
/// Input analysis receipt or path to scan.
#[arg(value_name = "INPUT")]
pub input: Option<PathBuf>,
/// Path to policy file (TOML format).
#[arg(long)]
pub policy: Option<PathBuf>,
/// Path to baseline receipt for ratchet comparison.
///
/// When provided, gate will evaluate ratchet rules comparing current
/// metrics against the baseline values.
#[arg(long, value_name = "PATH")]
pub baseline: Option<PathBuf>,
/// Path to ratchet config file (TOML format).
///
/// Defines rules for comparing current metrics against baseline.
/// Can also be specified inline in tokmd.toml under [[gate.ratchet]].
#[arg(long, value_name = "PATH")]
pub ratchet_config: Option<PathBuf>,
/// Analysis preset (for compute-then-gate mode).
#[arg(long, value_enum)]
pub preset: Option<AnalysisPreset>,
/// Output format.
#[arg(long, value_enum, default_value_t = GateFormat::Text)]
pub format: GateFormat,
/// Fail fast on first error.
#[arg(long)]
pub fail_fast: bool,
}
#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "kebab-case")]
pub enum GateFormat {
/// Human-readable text output.
#[default]
Text,
/// JSON output.
Json,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn gate_format_default_is_text() {
assert_eq!(GateFormat::default(), GateFormat::Text);
}
}