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]] [[package]]
name = "nhentairs" name = "nhentairs"
version = "0.4.0" version = "0.5.0"
dependencies = [ dependencies = [
"reqwest", "reqwest",
"serde", "serde",

View File

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

View File

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