holey-bytes/lang/src/main.rs

18 lines
571 B
Rust
Raw Normal View History

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