Skip to content

Add ability to upgrade the mods of all profiles #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ pub enum SubCommands {
/// A case-insensitive list of names of a mods to remove
mod_names: Vec<String>,
},
/// 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)]
Expand Down
21 changes: 17 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
},
};

Expand Down
5 changes: 5 additions & 0 deletions src/subcommands/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down