summaryrefslogtreecommitdiff
path: root/matrix-bin/src/repl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-bin/src/repl.rs')
-rw-r--r--matrix-bin/src/repl.rs25
1 files changed, 25 insertions, 0 deletions
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);
+ }
+ }
+ }
+
+}