zk2_check/zk2-check.rs
1//! Validates contract files and prints each one's fingerprint.
2//!
3//! ```text
4//! cargo run -p zenkey-model --example zk2-check -- examples/zk2/walkthrough/*.toml
5//! ```
6//!
7//! Exit 0 when every file is valid, 1 when one is not.
8
9use std::path::Path;
10
11use zenkey_model::canonical::Fingerprint;
12use zenkey_model::contract::load_path;
13
14fn main() {
15 let mut ok = true;
16 for arg in std::env::args().skip(1) {
17 let l = load_path(Path::new(&arg));
18 print!("{}", l.report);
19 match l.contract {
20 Some(c) => println!("{arg}: {} {}", c.iface, Fingerprint::of(&c)),
21 None => {
22 println!("{arg}: invalid");
23 ok = false;
24 }
25 }
26 }
27 std::process::exit(i32::from(!ok));
28}