holey-bytes/lang/src/main.rs

21 lines
648 B
Rust
Raw Normal View History

2024-09-30 12:09:17 -05:00
#[cfg(feature = "std")]
fn main() {
2024-09-30 12:35:25 -05:00
use std::io::Write;
2024-09-30 12:09:17 -05:00
fn run(out: &mut Vec<u8>) -> std::io::Result<()> {
let args = std::env::args().collect::<Vec<_>>();
let args = args.iter().map(String::as_str).collect::<Vec<_>>();
2024-09-30 12:27:00 -05:00
let opts = hblang::Options::from_args(&args, out)?;
let file = args.iter().filter(|a| !a.starts_with('-')).nth(1).copied().unwrap_or("main.hb");
hblang::run_compiler(file, opts, out)
}
2024-05-12 17:02:32 -05:00
2024-09-30 12:09:17 -05:00
let mut out = Vec::new();
match run(&mut out) {
Ok(_) => std::io::stdout().write_all(&out).unwrap(),
Err(_) => std::io::stderr().write_all(&out).unwrap(),
}
2024-05-12 17:02:32 -05:00
}