2024-07-08 04:00:35 -05:00
|
|
|
use std::num::NonZeroUsize;
|
|
|
|
|
2024-06-01 13:30:07 -05:00
|
|
|
fn main() -> std::io::Result<()> {
|
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-05-12 17:02:32 -05:00
|
|
|
|
2024-06-25 14:41:12 -05:00
|
|
|
if args.contains(&"--help") || args.contains(&"-h") {
|
|
|
|
println!("Usage: hbc [OPTIONS...] <FILE>");
|
|
|
|
println!(include_str!("../command-help.txt"));
|
|
|
|
return Err(std::io::ErrorKind::Other.into());
|
|
|
|
}
|
2024-05-12 17:02:32 -05:00
|
|
|
|
2024-07-06 07:58:50 -05:00
|
|
|
hblang::run_compiler(
|
|
|
|
args.get(1).copied().unwrap_or("main.hb"),
|
|
|
|
hblang::Options {
|
2024-07-08 00:22:53 -05:00
|
|
|
fmt: args.contains(&"--fmt"),
|
2024-07-06 07:58:50 -05:00
|
|
|
fmt_current: args.contains(&"--fmt-current"),
|
2024-07-08 04:00:35 -05:00
|
|
|
extra_threads: args
|
|
|
|
.iter()
|
|
|
|
.position(|&a| a == "--threads")
|
|
|
|
.map(|i| args[i + 1].parse::<NonZeroUsize>().expect("--threads expects integer"))
|
|
|
|
.map_or(1, NonZeroUsize::get)
|
|
|
|
- 1,
|
2024-07-06 07:58:50 -05:00
|
|
|
},
|
|
|
|
&mut std::io::stdout(),
|
|
|
|
)
|
2024-05-12 17:02:32 -05:00
|
|
|
}
|