use endbasic_core::exec::{Machine, StopReason};
use futures_lite::future::block_on;
const INPUT: &str = r#"
foo_value = 123
enable_bar = (foo_value > 122)
'enable_baz = "this is commented out"
"#;
fn main() {
let mut machine = Machine::default();
loop {
match block_on(machine.exec(&mut INPUT.as_bytes())).expect("Execution error") {
StopReason::Eof => break,
StopReason::Exited(i) => println!("Script explicitly exited with code {}", i),
StopReason::Break => (), }
}
match machine.get_var_as_int("foo_value") {
Ok(i) => println!("foo_value is {}", i),
Err(e) => println!("Input did not contain foo_value: {}", e),
}
match machine.get_var_as_bool("enable_bar") {
Ok(b) => println!("enable_bar is {}", b),
Err(e) => println!("Input did not contain enable_bar: {}", e),
}
match machine.get_var_as_string("enable_baz") {
Ok(b) => println!("enable_bar is {}", b),
Err(e) => println!("enable_baz is not set: {}", e),
}
}