Skip to content

Commit

Permalink
Merge 'cli: handle remaining input on EOF' from Konstantinos Artopoulos
Browse files Browse the repository at this point in the history
Fixes #966

Closes #975
  • Loading branch information
penberg committed Feb 11, 2025
2 parents 1da4326 + 839e1ce commit cca8ef9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cli/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
1 change: 1 addition & 0 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ fn main() -> anyhow::Result<()> {
continue;
}
Err(ReadlineError::Eof) => {
app.handle_remaining_input();
let _ = app.close_conn();
break;
}
Expand Down

0 comments on commit cca8ef9

Please sign in to comment.