summaryrefslogtreecommitdiff
path: root/matrix-bin/src/repl.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-02-19 18:38:15 -0500
committerFreya Murphy <freya@freyacat.org>2024-02-19 18:38:15 -0500
commitef4ada62f82ced8116e6ef64bdd773c275ea8195 (patch)
treeebd6e5c8c60510bf04998b7dccdb440883633763 /matrix-bin/src/repl.rs
parentdocs (diff)
downloadmatrix-ef4ada62f82ced8116e6ef64bdd773c275ea8195.tar.gz
matrix-ef4ada62f82ced8116e6ef64bdd773c275ea8195.tar.bz2
matrix-ef4ada62f82ced8116e6ef64bdd773c275ea8195.zip
things
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);
+ }
+ }
+ }
+
+}