Skip to content

Commit 1371522

Browse files
committed
add -s/--short option to ferium upgrade to hide compatible mods
1 parent 0304b52 commit 1371522

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/cli.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ pub enum SubCommands {
9090
/// List of project IDs or case-insensitive names of mods to remove
9191
mod_names: Vec<String>,
9292
},
93-
/// Download and install the latest compatible version of your mods
94-
Upgrade,
93+
/// Download and install the latest version of the mods specified
94+
Upgrade {
95+
#[clap(long, short)]
96+
/// Don’t print compatible mods
97+
short: bool,
98+
},
9599
}
96100

97101
#[derive(Subcommand)]

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,11 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
387387
check_empty_profile(profile)?;
388388
subcommands::remove(profile, mod_names)?;
389389
}
390-
SubCommands::Upgrade => {
390+
SubCommands::Upgrade { short } => {
391391
check_internet().await?;
392392
let profile = get_active_profile(&mut config)?;
393393
check_empty_profile(profile)?;
394-
subcommands::upgrade(modrinth, curseforge, github, profile).await?;
394+
subcommands::upgrade(modrinth, curseforge, github, profile, short).await?;
395395
}
396396
};
397397

src/subcommands/upgrade.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub async fn get_platform_downloadables(
6161
curseforge: Furse,
6262
github: Octocrab,
6363
profile: &Profile,
64+
short: bool,
6465
) -> Result<(Vec<PlatformDownloadable>, bool)> {
6566
let to_download = Arc::new(Mutex::new(Vec::new()));
6667
let progress_bar = Arc::new(Mutex::new(
@@ -72,7 +73,7 @@ pub async fn get_platform_downloadables(
7273
let modrinth = Arc::new(modrinth);
7374
let github = Arc::new(github);
7475

75-
println!("{}\n", "Determining the Latest Compatible Versions".bold());
76+
println!("{}", "Determining the Latest Compatible Versions".bold());
7677
let semaphore = Arc::new(Semaphore::new(75));
7778
progress_bar
7879
.lock()
@@ -144,16 +145,18 @@ pub async fn get_platform_downloadables(
144145
progress_bar.inc(1);
145146
match result {
146147
Ok((downloadable, backwards_compat)) => {
147-
progress_bar.println(format!(
148-
"{} {:43} {}",
149-
if backwards_compat {
150-
YELLOW_TICK.clone()
151-
} else {
152-
TICK.clone()
153-
},
154-
mod_.name,
155-
downloadable.filename().dimmed()
156-
));
148+
if !short {
149+
progress_bar.println(format!(
150+
"{} {:43} {}",
151+
if backwards_compat {
152+
YELLOW_TICK.clone()
153+
} else {
154+
TICK.clone()
155+
},
156+
mod_.name,
157+
downloadable.filename().dimmed()
158+
));
159+
}
157160
{
158161
to_download
159162
.lock()
@@ -211,9 +214,10 @@ pub async fn upgrade(
211214
curseforge: Furse,
212215
github: Octocrab,
213216
profile: &Profile,
217+
short: bool,
214218
) -> Result<()> {
215219
let (to_download, error) =
216-
get_platform_downloadables(modrinth, curseforge, github, profile).await?;
220+
get_platform_downloadables(modrinth, curseforge, github, profile, short).await?;
217221
let mut to_download = to_download
218222
.into_iter()
219223
.map(TryInto::try_into)

0 commit comments

Comments
 (0)