From 839e1ce3e8b95b1ef4f95e5a2da9be95d99802ad Mon Sep 17 00:00:00 2001 From: Konstantinos Artopoulos Date: Tue, 11 Feb 2025 00:02:20 +0200 Subject: [PATCH] fix(cli): handle remaining input on EOF --- cli/app.rs | 20 ++++++++++++++++++++ cli/main.rs | 1 + 2 files changed, 21 insertions(+) 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 { 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; }