#[cfg(feature = "verification")]
use std::env;
use crate::commands::require_project_root;
use crate::ui;
pub(crate) fn cmd_verify(license: Option<String>) -> Result<(), Box<dyn std::error::Error>> {
let project_root = require_project_root()?;
run_verification(&project_root, license.as_deref())?;
ui::info("Verification passed");
Ok(())
}
#[cfg(feature = "verification")]
pub(crate) fn run_verification(
project_root: &std::path::Path,
license: Option<&str>,
) -> Result<(), Box<dyn std::error::Error>> {
use crate::project::manifest::Manifest;
use logicaffeine_verify::{LicenseValidator, Verifier};
use std::fs;
let license_key = license
.map(String::from)
.or_else(|| env::var("LOGOS_LICENSE").ok());
let license_key = license_key.ok_or(
"Verification requires a license key.\n\
Use --license <key> or set LOGOS_LICENSE environment variable.\n\
Get a license at https://logicaffeine.com/pricing",
)?;
println!("Validating license...");
let validator = LicenseValidator::new();
let plan = validator.validate(&license_key)?;
println!("License valid ({})", plan);
let manifest = Manifest::load(project_root)?;
let entry_path = project_root.join(&manifest.package.entry);
let _source = fs::read_to_string(&entry_path)?;
println!("Running Z3 verification...");
let verifier = Verifier::new();
verifier.check_bool(true)?;
Ok(())
}
#[cfg(not(feature = "verification"))]
pub(crate) fn run_verification(
_project_root: &std::path::Path,
_license: Option<&str>,
) -> Result<(), Box<dyn std::error::Error>> {
Err(crate::ui::CliError::with_hint(
"this largo build does not include Z3 verification",
"install the full build: `curl -fsSL https://logicaffeine.com/install.sh | sh -s -- --full` \
(or build from source with `cargo install logicaffeine-cli --features verification`)",
)
.into())
}