matrix/matrix-bin/src/repl.rs
2024-02-19 18:38:15 -05:00

25 lines
482 B
Rust

use crate::State;
pub struct Repl<'a> {
state: State<'a>
}
impl<'a> Repl<'a> {
pub fn new(state: State<'a>) -> Self {
Self { state }
}
pub fn run(&mut self) {
let mut rl = rustyline::DefaultEditor::new().unwrap();
loop {
let Ok(line) = rl.readline(">> ") else {
break;
};
if let Err(err) = self.state.execute(line) {
crate::error(err);
}
}
}
}