use clap::{Parser, Subcommand};
mod clove;
mod config;
mod diff;
mod docs;
mod history;
mod hooks;
mod init;
mod prime;
mod project;
mod report;
mod runner;
mod spec;
mod test;
#[derive(Parser)]
#[command(name = "cm")]
#[command(about = "Checkmate - API Testing Framework")]
#[command(version)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init {
#[arg(short = 'L', long)]
url: Option<String>,
#[arg(long)]
stealth: bool,
},
Clove {
#[command(subcommand)]
command: clove::CloveCommands,
},
Test {
#[command(subcommand)]
command: test::TestCommands,
},
Diff {
#[command(subcommand)]
command: diff::DiffCommands,
},
Spec {
#[command(subcommand)]
command: spec::SpecCommands,
},
Config {
#[command(subcommand)]
command: config::ConfigCommands,
},
Report {
#[command(subcommand)]
command: report::ReportCommands,
},
Docs,
Doc {
category: String,
},
Onboard,
History {
#[arg(long)]
commit: Option<String>,
#[arg(long)]
spec: Option<String>,
#[arg(short = 'n', long, default_value = "10")]
limit: usize,
},
Show {
run_id: String,
},
Prime,
}
fn main() {
rustls::crypto::ring::default_provider()
.install_default()
.expect("Failed to install rustls crypto provider");
let cli = Cli::parse();
let result = match cli.command {
Commands::Init { url, stealth } => {
init::run(init::InitOptions { url, stealth })
}
Commands::Clove { command } => clove::run(command),
Commands::Test { command } => test::run(command),
Commands::Diff { command } => diff::run(command),
Commands::Spec { command } => spec::run(command),
Commands::Config { command } => config::run(command),
Commands::Report { command } => report::run(command),
Commands::Docs => docs::run_docs(),
Commands::Doc { category } => docs::run_doc(&category),
Commands::Onboard => docs::run_onboard(),
Commands::History { commit, spec, limit } => {
history::run_history(commit.as_deref(), spec.as_deref(), limit)
}
Commands::Show { run_id } => history::run_show(&run_id),
Commands::Prime => prime::run(),
};
if let Err(e) = result {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}