matrix/matrix-bin/src/repl.rs

26 lines
482 B
Rust
Raw Normal View History

2024-02-19 23:38:15 +00:00
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);
}
}
}
}