From ef4ada62f82ced8116e6ef64bdd773c275ea8195 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Mon, 19 Feb 2024 18:38:15 -0500 Subject: things --- matrix-bin/src/repl.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 matrix-bin/src/repl.rs (limited to 'matrix-bin/src/repl.rs') diff --git a/matrix-bin/src/repl.rs b/matrix-bin/src/repl.rs new file mode 100644 index 0000000..81fd289 --- /dev/null +++ b/matrix-bin/src/repl.rs @@ -0,0 +1,25 @@ +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); + } + } + } + +} -- cgit v1.2.3-freya