Print extra new line on the correct output

This commit is contained in:
blank X 2020-12-05 00:08:40 +07:00
parent c5b61bac25
commit cf9adfd203
3 changed files with 14 additions and 9 deletions

2
Cargo.lock generated
View File

@ -421,7 +421,7 @@ dependencies = [
[[package]]
name = "nhentairs"
version = "0.4.0"
version = "0.5.0"
dependencies = [
"reqwest",
"serde",

View File

@ -1,6 +1,6 @@
[package]
name = "nhentairs"
version = "0.4.0"
version = "0.5.0"
authors = ["blank X <theblankx@protonmail.com>"]
edition = "2018"

View File

@ -9,8 +9,7 @@ extern crate reqwest;
pub async fn run(args: env::Args) {
let sauces = utils::get_arg_sauces(args).unwrap();
let mut remaining_to_show = sauces.len();
if remaining_to_show < 1 {
if sauces.len() < 1 {
eprintln!("Missing sauce(s)");
exit(1);
}
@ -23,19 +22,25 @@ pub async fn run(args: env::Args) {
}));
}
let mut fail = false;
let mut one_done = false;
for handle in handles {
let (sauce_info, sauce) = handle.await.unwrap();
match sauce_info {
structs::GalleryInfo::Info(sauce_info) => println!("{}", utils::human_sauce_info(&sauce_info)),
structs::GalleryInfo::Info(sauce_info) => {
if one_done {
println!("");
}
println!("{}", utils::human_sauce_info(&sauce_info));
},
structs::GalleryInfo::Error(sauce_error) => {
if one_done {
eprintln!("");
}
eprintln!("Sauce: {}\nError: {}", sauce, sauce_error.error);
fail = true;
}
};
if remaining_to_show > 1 {
println!("");
remaining_to_show -= 1;
}
one_done = true;
}
if fail {
exit(1);