Repository: tursodatabase/limbo (language: rust)

Issue:
Shell input handling is incompatible with `sqlite3`
If I run multiple statements with `sqlite3`, I get output of all commands:

```
limbo % echo ".show\nSELECT 1" | sqlite3
        echo: off
         eqp: off
     explain: auto
     headers: off
        mode: list
   nullvalue: ""
      output: stdout
colseparator: "|"
rowseparator: "\n"
       stats: off
       width:
    filename: :memory:
1
```

However, `limbo`, returns output from just the first command:

```
limbo % echo ".show\nSELECT 1" | cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.49s
     Running `target/debug/limbo`
Settings:
Output mode: pretty
DB: :memory:
Output: STDOUT
Null value:
CWD: /Users/penberg/src/penberg/limbo
Echo: off
```


Discussion / hints:

Fix patch:
diff --git a/cli/app.rs b/cli/app.rs
index b4d029648..69cbd7934 100644
--- a/cli/app.rs
+++ b/cli/app.rs
@@ -865,6 +865,26 @@ impl Limbo {
 
         Ok(())
     }
+
+    pub fn handle_remaining_input(&mut self) {
+        if self.input_buff.is_empty() {
+            return;
+        }
+
+        let buff = self.input_buff.clone();
+        let echo = self.opts.echo;
+        if echo {
+            let _ = self.writeln(&buff);
+        }
+        let conn = self.conn.clone();
+        let runner = conn.query_runner(buff.as_bytes());
+        for output in runner {
+            if let Err(e) = self.print_query_result(&buff, output) {
+                let _ = self.writeln(e.to_string());
+            }
+        }
+        self.reset_input();
+    }
 }
 
 fn get_writer(output: &str) -> Box<dyn Write> {
diff --git a/cli/main.rs b/cli/main.rs
index df4aa9787..566cb2d48 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -36,6 +36,7 @@ fn main() -> anyhow::Result<()> {
                 continue;
             }
             Err(ReadlineError::Eof) => {
+                app.handle_remaining_input();
                 let _ = app.close_conn();
                 break;
             }


Test patch: