40 lines
1,000 B
Rust
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);
|
|
}
|
|
}
|