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 {
|
loop {
|
||||||
|
|
||||||
query.clear();
|
query.clear();
|
||||||
if options.interactive || query.trim().is_empty() {
|
query = options.query.trim().to_string().clone();
|
||||||
while query.trim().is_empty() || query.trim() == ":" || query.trim() == ":" {
|
if options.interactive || options.query.trim().is_empty() {
|
||||||
|
while query.is_empty() || query == ":" || query == ":" || query == "_" || query == "_" {
|
||||||
query.clear();
|
query.clear();
|
||||||
print!("=> ");
|
print!("=> ");
|
||||||
stdout().flush().unwrap();
|
stdout().flush().unwrap();
|
||||||
|
@ -55,12 +56,10 @@ fn main() -> Result<(), ureq::Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
query = options.query.clone();
|
if query == ":" || query == ":" || query == "_" || query == "_" {
|
||||||
if query.trim() == ":" || query.trim() == ":" || query.trim() == "_" || query.trim() == "_" {
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
query = query.trim().to_string();
|
|
||||||
|
|
||||||
let mut lines_output = 0;
|
let mut lines_output = 0;
|
||||||
let mut output = String::with_capacity(51200); /* Give output 50KiB of buffer; Should be enough to avoid reallocs*/
|
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 {
|
} else {
|
||||||
print!("{}", output);
|
print!("{}", output);
|
||||||
}
|
}
|
||||||
if !options.interactive {
|
if !options.interactive && !options.query.trim().is_empty() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue