1use std::io::Write;
2
3fn main() {
4 unsafe { mri_sys::ruby_init() };
5
6 loop {
7 print!("cool-interpreter:8=====D -- ");
8 std::io::stdout().flush().unwrap();
9
10 let mut input = String::new();
11 std::io::stdin().read_line(&mut input).expect("could not read from stdin");
12
13 match &input.trim().to_lowercase()[..] {
14 "exit" | "quit" => break,
15 "help" => println!("-> https://www.eapservices.co.nz/"),
16 _ => match mri_sys::helpers::eval(&input, mri_sys::helpers::Binding::top_level(), Some("mock-filename.rb")) {
17 Ok(value) => println!("-> {:?}", value),
18 Err(e) => eprintln!("ERROR, EXCEPTION RAISED: {}", e),
19 },
20 }
21 }
22
23 unsafe { mri_sys::ruby_cleanup(0) };
24}