Skip to content

Commit

Permalink
Avoid repetition at all stages
Browse files Browse the repository at this point in the history
  • Loading branch information
AOx0 committed Jul 19, 2022
1 parent ae1b69a commit 0163138
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
6 changes: 5 additions & 1 deletion src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pub async fn install(
d: usize,
mut already_installed: HashSet<String>,
) {
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();
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -291,7 +295,7 @@ pub async fn install(
}
}
});

let result = {
let mut result = String::new();
let mut num = ids.len();
Expand Down

0 comments on commit 0163138

Please sign in to comment.