use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(name = "wickra-proof", version, about)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand, Debug)]
pub enum Command {
Prove {
#[arg(long)]
spec: PathBuf,
#[arg(long)]
data: PathBuf,
#[arg(long, value_enum, default_value_t = Format::Json)]
format: Format,
},
Verify {
#[arg(long)]
proof: PathBuf,
#[arg(long)]
spec: PathBuf,
#[arg(long)]
data: PathBuf,
},
Canonicalize {
#[arg(long)]
file: PathBuf,
},
Version,
}
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq)]
pub enum Format {
Json,
Text,
}
#[cfg(test)]
mod tests {
use super::*;
use clap::CommandFactory;
#[test]
fn arg_config_is_valid() {
Cli::command().debug_assert();
}
#[test]
fn prove_parses_with_defaults() {
let cli = Cli::try_parse_from([
"wickra-proof",
"prove",
"--spec",
"s.json",
"--data",
"d.csv",
])
.unwrap();
match cli.command {
Command::Prove { format, .. } => assert_eq!(format, Format::Json),
_ => panic!("expected prove"),
}
}
#[test]
fn verify_requires_all_three_paths() {
assert!(Cli::try_parse_from(["wickra-proof", "verify", "--proof", "p.json"]).is_err());
}
#[test]
fn version_subcommand_parses() {
let cli = Cli::try_parse_from(["wickra-proof", "version"]).unwrap();
assert!(matches!(cli.command, Command::Version));
}
}