use clap::{Parser, Subcommand, ValueEnum, ValueHint};
use clap_complete::Shell;
#[derive(Parser)]
#[command(name = "anc", version, about = "The agent-native CLI linter")]
#[command(arg_required_else_help = true)]
#[command(
after_help = "When the first argument is not a subcommand, `check` is inserted automatically:
anc . ≡ anc check .
anc --command ripgrep ≡ anc check --command ripgrep
Bare `anc` (no arguments) prints this help and exits 2 — a deliberate guard
that prevents recursive self-invocation when agentnative checks itself."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
#[arg(long, short = 'q', global = true, env = "AGENTNATIVE_QUIET")]
pub quiet: bool,
}
#[derive(Subcommand)]
pub enum Commands {
Check {
#[arg(default_value = ".")]
path: std::path::PathBuf,
#[arg(
long,
value_name = "NAME",
value_hint = ValueHint::CommandName,
conflicts_with = "path",
conflicts_with = "source",
)]
command: Option<String>,
#[arg(long)]
binary: bool,
#[arg(long)]
source: bool,
#[arg(long)]
principle: Option<u8>,
#[arg(long, default_value = "text")]
output: OutputFormat,
#[arg(long)]
include_tests: bool,
},
Completions {
shell: Shell,
},
Generate {
#[command(subcommand)]
artifact: GenerateKind,
},
}
#[derive(Subcommand)]
pub enum GenerateKind {
CoverageMatrix {
#[arg(long, value_name = "PATH", default_value = "docs/coverage-matrix.md")]
out: std::path::PathBuf,
#[arg(
long = "json-out",
value_name = "PATH",
default_value = "coverage/matrix.json"
)]
json_out: std::path::PathBuf,
#[arg(long)]
check: bool,
},
}
#[derive(Clone, ValueEnum)]
pub enum OutputFormat {
Text,
Json,
}