mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 09:34:18 +01:00
fix(cli): handle remaining input on EOF
This commit is contained in:
20
cli/app.rs
20
cli/app.rs
@@ -865,6 +865,26 @@ impl Limbo {
|
|||||||
|
|
||||||
Ok(())
|
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> {
|
fn get_writer(output: &str) -> Box<dyn Write> {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Err(ReadlineError::Eof) => {
|
Err(ReadlineError::Eof) => {
|
||||||
|
app.handle_remaining_input();
|
||||||
let _ = app.close_conn();
|
let _ = app.close_conn();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user