Skip to content

Commit

Permalink
add -l/--less option to ferium upgrade to hide compatible mods
Browse files Browse the repository at this point in the history
  • Loading branch information
tippfehlr committed May 16, 2023
1 parent 0304b52 commit 7c4b16f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
8 changes: 6 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ pub enum SubCommands {
/// List of project IDs or case-insensitive names of mods to remove
mod_names: Vec<String>,
},
/// Download and install the latest compatible version of your mods
Upgrade,
/// Download and install the latest version of the mods specified
Upgrade {
#[clap(long, short)]
/// Don’t print compatible mods
less: bool,
},
}

#[derive(Subcommand)]
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
check_empty_profile(profile)?;
subcommands::remove(profile, mod_names)?;
}
SubCommands::Upgrade => {
SubCommands::Upgrade { less } => {
check_internet().await?;
let profile = get_active_profile(&mut config)?;
check_empty_profile(profile)?;
subcommands::upgrade(modrinth, curseforge, github, profile).await?;
subcommands::upgrade(modrinth, curseforge, github, profile, less).await?;
}
};

Expand Down
25 changes: 14 additions & 11 deletions src/subcommands/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub async fn get_platform_downloadables(
curseforge: Furse,
github: Octocrab,
profile: &Profile,
less: bool,
) -> Result<(Vec<PlatformDownloadable>, bool)> {
let to_download = Arc::new(Mutex::new(Vec::new()));
let progress_bar = Arc::new(Mutex::new(
Expand All @@ -72,7 +73,7 @@ pub async fn get_platform_downloadables(
let modrinth = Arc::new(modrinth);
let github = Arc::new(github);

println!("{}\n", "Determining the Latest Compatible Versions".bold());
println!("{}", "Determining the Latest Compatible Versions".bold());
let semaphore = Arc::new(Semaphore::new(75));
progress_bar
.lock()
Expand Down Expand Up @@ -144,16 +145,18 @@ pub async fn get_platform_downloadables(
progress_bar.inc(1);
match result {
Ok((downloadable, backwards_compat)) => {
progress_bar.println(format!(
"{} {:43} {}",
if backwards_compat {
YELLOW_TICK.clone()
} else {
TICK.clone()
},
mod_.name,
downloadable.filename().dimmed()
));
if !less {
progress_bar.println(format!(
"{} {:43} {}",
if backwards_compat {
YELLOW_TICK.clone()
} else {
TICK.clone()
},
mod_.name,
downloadable.filename().dimmed()
));
}
{
to_download
.lock()
Expand Down

0 comments on commit 7c4b16f

Please sign in to comment.