diff --git a/cli/app.rs b/cli/app.rs index cda23681a..4bdeeb788 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -310,13 +310,7 @@ impl Limbo { if cmd.trim().starts_with('.') { self.handle_dot_command(cmd); } else { - let conn = self.conn.clone(); - let runner = conn.query_runner(cmd.as_bytes()); - for output in runner { - if let Err(e) = self.print_query_result(cmd, output) { - let _ = self.writeln(e.to_string()); - } - } + self.run_query(cmd); } std::process::exit(0); } @@ -876,17 +870,7 @@ impl Limbo { } 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.run_query(buff.as_str()); self.reset_input(); } } diff --git a/cli/main.rs b/cli/main.rs index 566cb2d48..63a45d7d9 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -4,7 +4,7 @@ mod import; mod opcodes_dictionary; use rustyline::{error::ReadlineError, DefaultEditor}; -use std::sync::atomic::Ordering; +use std::{io::IsTerminal, sync::atomic::Ordering}; fn main() -> anyhow::Result<()> { env_logger::init(); @@ -15,6 +15,7 @@ fn main() -> anyhow::Result<()> { if history_file.exists() { rl.load_history(history_file.as_path())?; } + let is_terminal = std::io::stdin().is_terminal(); loop { let readline = rl.readline(&app.prompt); match readline {