This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
huia/huiac/src/main.rs
2019-02-04 14:18:44 +13:00

40 lines
1,000 B
Rust

#![forbid(unsafe_code)]
extern crate ansi_term;
extern crate clap;
extern crate huia_compiler;
extern crate term_size;
mod error;
mod terminal;
use clap::{App, Arg};
use error::Error;
use std::process;
/// Version number of the huiac crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() {
let matches = App::new("huiac")
.version(VERSION)
.author("James Harton <james@automat.nz>")
.about("The CLI for the Huia programming language compiler.")
.arg(
Arg::with_name("INPUT")
.help("The source file to compile")
.required(true)
.index(1),
).get_matches();
let source_path = matches.value_of("INPUT").unwrap();
let result = huia_compiler::compile_file(source_path);
if result.is_ok() {
println!("{:#?}", result.unwrap());
process::exit(0);
} else {
println!("{}", Error::from(result.err().unwrap()));
process::exit(1);
}
}