remove repeated code

This commit is contained in:
Ihor Andrianov
2025-02-12 02:34:13 +02:00
parent a5fcbed21a
commit 287c04bde0
2 changed files with 4 additions and 19 deletions

View File

@@ -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();
}
}

View File

@@ -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 {