mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-02 06:44:23 +01:00
remove repeated code
This commit is contained in:
20
cli/app.rs
20
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user