don't do empty requests

This commit is contained in:
jojii 2021-04-07 13:57:16 +02:00
parent d017288de4
commit c168323282
No known key found for this signature in database
GPG key ID: 87B75C673974601F
2 changed files with 19 additions and 15 deletions

View file

@ -34,11 +34,12 @@ fn main() -> Result<(), ureq::Error> {
let mut query = {
if options.interactive {
print!("=> ");
stdout().flush().unwrap();
let mut o = String::new();
stdin().read_line(&mut o).expect("Can't read from stdin");
while o.trim().is_empty() {
print!("=> ");
stdout().flush().unwrap();
stdin().read_line(&mut o).expect("Can't read from stdin");
}
o
} else {
options.query.clone()
@ -84,18 +85,21 @@ fn main() -> Result<(), ureq::Error> {
println!();
}
}
println!();
}
if !options.interactive {
break;
}
print!("\n=> ");
stdout().flush().unwrap();
query.clear();
stdin()
.read_line(&mut query)
.expect("Can't read from stdin");
while query.trim().is_empty() {
print!("=> ");
stdout().flush().unwrap();
stdin()
.read_line(&mut query)
.expect("Can't read from stdin");
}
}
Ok(())