use clap::Args;
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub enum VerifyMode {
#[value(help = "Auto-detect: verify all functions with unsafe callees or struct invariants")]
Scan,
#[value(help = "Only verify functions annotated with #[rapx::verify]")]
Targeted,
#[value(help = "Like `scan` or `targeted` but skip struct invariant checks")]
Invless,
}
#[derive(Debug, Clone)]
pub enum PostfixRepeat {
Auto,
Fixed(usize),
}
impl std::fmt::Display for PostfixRepeat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PostfixRepeat::Auto => write!(f, "auto"),
PostfixRepeat::Fixed(n) => write!(f, "{n}"),
}
}
}
impl std::str::FromStr for PostfixRepeat {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if s.eq_ignore_ascii_case("auto") {
Ok(PostfixRepeat::Auto)
} else {
s.parse::<usize>()
.map(PostfixRepeat::Fixed)
.map_err(|_| format!("expected 'auto' or a non-negative integer, got '{s}'"))
}
}
}
#[derive(Debug, Clone, Args)]
pub struct VerifyArgs {
#[arg(long)]
pub prepare_targets: bool,
#[arg(long, default_value = "auto", value_parser = clap::value_parser!(PostfixRepeat))]
pub postfix_repeat: PostfixRepeat,
#[arg(long, default_value = "scan")]
pub mode: VerifyMode,
#[arg(long = "crate")]
pub crate_name: Option<String>,
#[arg(long)]
pub module: Option<String>,
#[arg(long)]
pub debug_contracts: bool,
}