oysh/crates/oyster/src/main.rs

25 lines
522 B
Rust
Raw Normal View History

2022-09-15 20:16:37 +00:00
use std::process;
use oyster_lineedit::readline;
use oyster_parser::ast::Code;
2022-09-15 20:16:37 +00:00
use oyster_runtime::{Shell, Status};
2022-07-14 22:26:57 +00:00
fn main() {
let mut shell = Shell::new().unwrap();
shell.builtins_mut().add_defaults();
2022-09-15 20:16:37 +00:00
let mut exit_code = Status::SUCCESS;
loop {
let prog = readline("> ").unwrap();
if prog.trim() == "exit" {
break;
}
2022-09-15 20:16:37 +00:00
let ast = Code::try_from(prog.as_ref()).unwrap();
exit_code = shell.run(&ast).unwrap();
}
2022-09-15 20:16:37 +00:00
process::exit(exit_code.0);
2022-07-14 22:26:57 +00:00
}