From 0163138a1136939a6786a0636d55ea9948bf4d91 Mon Sep 17 00:00:00 2001 From: Alejandro Osornio <50227494+AOx0@users.noreply.github.com> Date: Tue, 19 Jul 2022 04:31:26 -0500 Subject: [PATCH] Avoid repetition at all stages --- src/args.rs | 2 +- src/install.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/args.rs b/src/args.rs index 3fb64cd..5b41408 100644 --- a/src/args.rs +++ b/src/args.rs @@ -240,7 +240,7 @@ pub struct Pull { } #[derive(Args, Debug, Clone)] -#[clap(arg_required_else_help = true)] +#[clap(arg_required_else_help = false)] pub struct Install { /// The name of the RimWorld mod(s) #[clap(required = false, default_value = "None")] diff --git a/src/install.rs b/src/install.rs index 181ba4b..6e14846 100644 --- a/src/install.rs +++ b/src/install.rs @@ -51,6 +51,9 @@ pub async fn install( d: usize, mut already_installed: HashSet, ) { + if args.is_debug() { + log!(Warning: "Already installed {:?}", already_installed); + } let inline: bool = !(args.r#mod.len() == 1 && args.r#mod.get(0).unwrap() == "None"); if !inline { args.r#mod = Vec::new(); @@ -210,6 +213,7 @@ pub async fn install( } let ids: Vec<&str> = to_install.iter().map(|e| e.id.as_str()).collect(); + let ids: Vec<_> = ids.into_iter().filter(|&id| !already_installed.contains(&id.to_owned()) ).collect(); if d == 0 { log!( Status: @@ -291,7 +295,7 @@ pub async fn install( } } }); - + let result = { let mut result = String::new(); let mut num = ids.len();