From cf9adfd203820b561f0f891fabbd015d60ffe25b Mon Sep 17 00:00:00 2001 From: blank X Date: Sat, 5 Dec 2020 00:08:40 +0700 Subject: [PATCH] Print extra new line on the correct output --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/view.rs | 19 ++++++++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 652f184..3c83a48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -421,7 +421,7 @@ dependencies = [ [[package]] name = "nhentairs" -version = "0.4.0" +version = "0.5.0" dependencies = [ "reqwest", "serde", diff --git a/Cargo.toml b/Cargo.toml index 899fb71..019026f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nhentairs" -version = "0.4.0" +version = "0.5.0" authors = ["blank X "] edition = "2018" diff --git a/src/commands/view.rs b/src/commands/view.rs index 46740d2..55ac7b4 100644 --- a/src/commands/view.rs +++ b/src/commands/view.rs @@ -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);