mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Accept arbitrary filenames in roc-cli
This commit is contained in:
parent
9892a27f21
commit
f7cfe1d396
1 changed files with 16 additions and 5 deletions
|
@ -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<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue