add exit/quit command to columnq-cli

This commit is contained in:
Qingping Hou 2021-09-18 22:05:49 -07:00
parent f72299f142
commit 57a1779a95

View File

@ -51,20 +51,22 @@ async fn console_loop(cq: &ColumnQ) -> anyhow::Result<()> {
match readline.readline("columnq(sql)> ") {
Ok(line) => {
readline.add_history_entry(line.as_str());
match cq.query_sql(&line).await {
Ok(batches) => {
pretty::print_batches(&batches)?;
}
Err(e) => {
println!("Error: {}", e);
match line.as_ref() {
"exit" | "quit" | "q" => {
println!("Good bye!");
break;
}
s => match cq.query_sql(s).await {
Ok(batches) => {
pretty::print_batches(&batches)?;
}
Err(e) => {
println!("Error: {}", e);
}
},
}
}
Err(ReadlineError::Interrupted) => {
println!("Good bye!");
break;
}
Err(ReadlineError::Eof) => {
Err(ReadlineError::Interrupted) | Err(ReadlineError::Eof) => {
println!("Good bye!");
break;
}