Exit with 1 if there's at least one fail on info

This commit is contained in:
blank X 2020-12-04 08:25:17 +07:00
parent cea920a080
commit 045bb9d6ca
3 changed files with 10 additions and 4 deletions

2
Cargo.lock generated
View File

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

View File

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

View File

@ -4,7 +4,6 @@ use crate::structs;
use std::env; use std::env;
use std::process::exit; use std::process::exit;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
//use std::collections::BTreeMap;
extern crate tokio; extern crate tokio;
extern crate reqwest; extern crate reqwest;
@ -23,15 +22,22 @@ pub async fn run(args: env::Args) {
(utils::get_sauce_info(cloned_client, sauce).await.unwrap(), sauce) (utils::get_sauce_info(cloned_client, sauce).await.unwrap(), sauce)
})); }));
} }
let mut fail = 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) => println!("{}", utils::human_sauce_info(&sauce_info)),
structs::GalleryInfo::Error(sauce_error) => eprintln!("Sauce: {}\nError: {}", sauce, sauce_error.error) structs::GalleryInfo::Error(sauce_error) => {
eprintln!("Sauce: {}\nError: {}", sauce, sauce_error.error);
fail = true;
}
}; };
if remaining_to_show > 1 { if remaining_to_show > 1 {
println!(""); println!("");
remaining_to_show -= 1; remaining_to_show -= 1;
} }
} }
if fail {
exit(1);
}
} }