1#![forbid(unsafe_code)]
7#![warn(missing_docs)]
8
9pub mod inspect;
10
11const USAGE: &str = "\
12Tickwise: record, replay, and diff deterministic simulations.
13
14Usage:
15 tickwise inspect <session.rec> show metadata and statistics for a recording
16 tickwise compare <a.rec> <b.rec> find the first divergent tick, arrives with M2
17 tickwise diff <a.dump> <b.dump> field-level structural diff, arrives with M3
18
19Options:
20 -h, --help show this help
21 -V, --version show the version
22";
23
24pub fn run(args: &[String]) -> u8 {
27 let Some((command, rest)) = args.split_first() else {
28 eprint!("{USAGE}");
29 return 2;
30 };
31
32 match command.as_str() {
33 "inspect" => match rest {
34 [path] => match inspect::render(path) {
35 Ok(report) => {
36 print!("{}", report.text);
37 u8::from(report.corrupt)
38 }
39 Err(err) => {
40 eprintln!("tickwise inspect: {err}");
41 1
42 }
43 },
44 _ => {
45 eprintln!("usage: tickwise inspect <session.rec>");
46 2
47 }
48 },
49 "compare" => {
50 eprintln!("tickwise compare is not implemented yet, it arrives with M2");
51 1
52 }
53 "diff" => {
54 eprintln!("tickwise diff is not implemented yet, it arrives with M3");
55 1
56 }
57 "help" | "-h" | "--help" => {
58 print!("{USAGE}");
59 0
60 }
61 "-V" | "--version" => {
62 println!("tickwise {}", env!("CARGO_PKG_VERSION"));
63 0
64 }
65 other => {
66 eprintln!("tickwise: unknown command {other}");
67 eprint!("{USAGE}");
68 2
69 }
70 }
71}