From 049e6d9dd811e27c9de1954c26ee9909fef2b1ef Mon Sep 17 00:00:00 2001 From: logistic-bot Date: Tue, 14 Feb 2023 21:22:58 +0100 Subject: [PATCH] Add ability to upgrade the mods of all profiles Closes #270 Also added an indicator to show which profile is currently being worked on. This is currently shown even if only one profile is being update --- src/cli.rs | 8 ++++++-- src/main.rs | 21 +++++++++++++++++---- src/subcommands/upgrade.rs | 5 +++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 67376d1e..3c2f7119 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -86,8 +86,12 @@ pub enum SubCommands { /// A case-insensitive list of names of a mods to remove mod_names: Vec, }, - /// Download and install the latest version of the mods specified - Upgrade, + /// Download and install the latest version of the mods of the selected profile + Upgrade { + /// Instead of only working on the selected profile, work on all profiles + #[clap(long, action=clap::ArgAction::SetTrue)] + all_profiles: bool, + }, } #[derive(Subcommand)] diff --git a/src/main.rs b/src/main.rs index 25a5561f..bfa5c1fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -355,11 +355,24 @@ async fn actual_main(cli_app: Ferium) -> Result<()> { check_empty_profile(profile)?; subcommands::remove(profile, mod_names)?; }, - SubCommands::Upgrade => { + SubCommands::Upgrade { all_profiles } => { check_internet().await?; - let profile = get_active_profile(&mut config)?; - check_empty_profile(profile)?; - subcommands::upgrade(modrinth, curseforge, github, profile).await?; + if all_profiles { + for profile in &config.profiles { + check_empty_profile(&profile)?; + subcommands::upgrade( + modrinth.clone(), + curseforge.clone(), + github.clone(), + &profile, + ) + .await?; + } + } else { + let profile = get_active_profile(&mut config)?; + check_empty_profile(profile)?; + subcommands::upgrade(modrinth, curseforge, github, profile).await?; + } }, }; diff --git a/src/subcommands/upgrade.rs b/src/subcommands/upgrade.rs index b20c6c2b..234021e7 100644 --- a/src/subcommands/upgrade.rs +++ b/src/subcommands/upgrade.rs @@ -41,6 +41,11 @@ pub async fn upgrade( let modrinth = Arc::new(modrinth); let github = Arc::new(github); + println!( + "{} Working on profile {}", + "==>".green().bold(), + profile.name.bold() + ); println!("{}\n", "Determining the Latest Compatible Versions".bold()); let semaphore = Arc::new(Semaphore::new(75)); progress_bar