Fix some bugs on empty inputs.
This commit is contained in:
parent
75bdf17905
commit
58d2c92e3a
1 changed files with 5 additions and 6 deletions
11
src/main.rs
11
src/main.rs
|
@ -44,8 +44,9 @@ fn main() -> Result<(), ureq::Error> {
|
|||
loop {
|
||||
|
||||
query.clear();
|
||||
if options.interactive || query.trim().is_empty() {
|
||||
while query.trim().is_empty() || query.trim() == ":" || query.trim() == ":" {
|
||||
query = options.query.trim().to_string().clone();
|
||||
if options.interactive || options.query.trim().is_empty() {
|
||||
while query.is_empty() || query == ":" || query == ":" || query == "_" || query == "_" {
|
||||
query.clear();
|
||||
print!("=> ");
|
||||
stdout().flush().unwrap();
|
||||
|
@ -55,12 +56,10 @@ fn main() -> Result<(), ureq::Error> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
query = options.query.clone();
|
||||
if query.trim() == ":" || query.trim() == ":" || query.trim() == "_" || query.trim() == "_" {
|
||||
if query == ":" || query == ":" || query == "_" || query == "_" {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
query = query.trim().to_string();
|
||||
|
||||
let mut lines_output = 0;
|
||||
let mut output = String::with_capacity(51200); /* Give output 50KiB of buffer; Should be enough to avoid reallocs*/
|
||||
|
@ -111,7 +110,7 @@ fn main() -> Result<(), ureq::Error> {
|
|||
} else {
|
||||
print!("{}", output);
|
||||
}
|
||||
if !options.interactive {
|
||||
if !options.interactive && !options.query.trim().is_empty() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue