-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathmain.rs
More file actions
62 lines (50 loc) · 1.66 KB
/
main.rs
File metadata and controls
62 lines (50 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
mod errors;
mod parse;
mod resolve;
mod shadow;
mod transform;
mod ui_test_shim;
use std::{env, process::exit};
use clap::Parser;
/// Hermes: A Literate Verification Toolchain
#[derive(Parser, Debug)]
#[command(name = "hermes", version, about, long_about = None)]
struct Cli {
#[command(flatten)]
resolve: resolve::Args,
}
fn main() {
if env::var("HERMES_UI_TEST_MODE").is_ok() {
ui_test_shim::run();
return;
}
let args = Cli::parse();
// TODO: Better error handling than `.unwrap()`.
let roots = resolve::resolve_roots(&args.resolve).unwrap();
// TODO: What artifacts need to be updated (not just copied)? E.g., do we
// need to update `Cargo.toml` to rewrite relative paths?
// TODO: From each root, parse and walk referenced modules.
let mut has_errors = false;
for (package, kind, path) in roots.roots {
let mut edits = Vec::new();
let res = parse::read_file_and_visit_hermes_items(&path, |_src, res| {
if let Err(e) = res {
has_errors = true;
eprint!("{:?}", miette::Report::new(e));
} else if let Ok(item) = res {
transform::append_edits(&item, &mut edits);
}
});
let source = res.unwrap_or_else(|e| {
eprintln!("Error parsing file: {}", e);
exit(1);
});
if has_errors {
exit(1);
}
let mut source = source.into_bytes();
transform::apply_edits(&mut source, &edits);
}
// TODO: Create shadow skeleton.
// shadow::create_shadow_skeleton(&roots.workspace, &roots.shadow_root, &roots.cargo_target_dir, todo!()).unwrap();
}