-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathmain.rs
More file actions
39 lines (33 loc) · 860 Bytes
/
main.rs
File metadata and controls
39 lines (33 loc) · 860 Bytes
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
mod errors;
mod parse;
mod ui_test_shim;
use std::{env, fs, path::PathBuf, process::exit};
fn main() {
if env::var("HERMES_UI_TEST_MODE").is_ok() {
ui_test_shim::run();
return;
}
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: hermes <file.rs>");
exit(1);
}
let file_path = PathBuf::from(&args[1]);
let source = match fs::read_to_string(&file_path) {
Ok(s) => s,
Err(e) => {
eprintln!("Error reading file: {}", e);
exit(1);
}
};
let mut has_errors = false;
parse::visit_hermes_items_in_file(&file_path, &source, |res| {
if let Err(e) = res {
has_errors = true;
eprint!("{:?}", miette::Report::new(e));
}
});
if has_errors {
exit(1);
}
}