Accept arbitrary filenames in roc-cli

This commit is contained in:
Richard Feldman 2019-06-23 18:55:10 -04:00
parent 9892a27f21
commit f7cfe1d396

View file

@ -9,7 +9,11 @@ use roc::parse;
use std::io;
fn main() -> std::io::Result<()> {
let mut file = File::open("Example.roc")?;
let argv = std::env::args().into_iter().collect::<Vec<String>>();
match argv.get(1) {
Some(filename) => {
let mut file = File::open(filename)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
@ -17,6 +21,13 @@ fn main() -> std::io::Result<()> {
let expr = parse::parse_string(contents.as_str()).unwrap();
process_task(eval(expr))
},
None => {
println!("Usage: roc FILENAME.roc");
Ok(())
}
}
}
fn process_task(evaluated: Evaluated) -> std::io::Result<()> {