mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 01:58:16 +00:00
fix(cli): handle remaining input on EOF
This commit is contained in:
parent
1da43266e9
commit
839e1ce3e8
2 changed files with 21 additions and 0 deletions
20
cli/app.rs
20
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> {
|
||||
|
|
|
@ -36,6 +36,7 @@ fn main() -> anyhow::Result<()> {
|
|||
continue;
|
||||
}
|
||||
Err(ReadlineError::Eof) => {
|
||||
app.handle_remaining_input();
|
||||
let _ = app.close_conn();
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue