schala/src/main.rs

35 lines
976 B
Rust
Raw Normal View History

use schala_repl::{run_noninteractive, start_repl, ProgrammingLanguageInterface};
2017-10-12 02:13:55 -07:00
use std::process::exit;
2015-07-16 01:40:37 -07:00
fn main() {
let args: Vec<String> = std::env::args().collect();
let matches = command_line_options()
.parse(&args[1..])
.unwrap_or_else(|e| {
eprintln!("Error parsing options: {}", e);
exit(1);
});
if matches.opt_present("help") {
println!("{}", command_line_options().usage("Schala metainterpreter"));
exit(0);
}
let langs: Vec<Box<dyn ProgrammingLanguageInterface>> =
vec![Box::new(schala_lang::Schala::new())];
if matches.free.is_empty() {
start_repl(langs);
} else {
run_noninteractive(&matches.free[0], langs);
}
}
fn command_line_options() -> getopts::Options {
let mut options = getopts::Options::new();
options.optflag("h", "help", "Show help text");
options.optflag("w", "webapp", "Start up web interpreter");
options
}