schala/src/main.rs

37 lines
1.0 KiB
Rust
Raw Normal View History

use schala_repl::{run_noninteractive, start_repl, ProgrammingLanguageInterface};
2017-10-12 02:13:55 -07:00
2021-10-07 02:19:24 -07:00
use std::path::PathBuf;
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 {
2021-10-07 02:19:24 -07:00
let paths = matches.free.iter().map(PathBuf::from).collect();
run_noninteractive(paths, 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
}