Skip to content

Commit c628c0e

Browse files
Added check overrides to add commands
1 parent 9d0f3b0 commit c628c0e

File tree

6 files changed

+141
-34
lines changed

6 files changed

+141
-34
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog for Ferium
22

3+
## `v3.25.0`
4+
### 04.05.2022
5+
6+
- Added `--dont_check_game_version` and `--dont_check_mod_loader` flags to add commands
7+
- The check overrides are follow when checking for dependencies
8+
- These check overrides will be added to the config automatically
9+
- Added Quilt->Fabric backwards compatibility to the add commands' dependency checking
10+
311
## `v3.24.0`
412
### 03.05.2022
513

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ferium"
3-
version = "3.24.0"
3+
version = "3.25.0"
44
edition = "2021"
55
authors = ["Ilesh Thiada (theRookieCoder) <[email protected]>", "Daniel Hauck (SolidTux)"]
66
description = "Ferium is a CLI program for managing Minecraft mods from Modrinth, CurseForge, and Github Releases"
@@ -31,7 +31,7 @@ dialoguer = "0.10"
3131
serde_json = "1.0"
3232
itertools = "0.10"
3333
colored = "2.0"
34-
ferinth = "2.1"
34+
ferinth = "2.2"
3535
libium = "1.11"
3636
anyhow = "1.0"
3737
online = "3.0"

src/cli.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,36 @@ pub enum SubCommands {
2424
AddModrinth {
2525
#[clap(help("The project ID is specified at the bottom of the left sidebar under 'Technical information'\nYou can also use the project slug for this"))]
2626
project_id: String,
27+
#[clap(long)]
28+
#[clap(help("Whether the game version should be checked for this mod"))]
29+
dont_check_game_version: bool,
30+
#[clap(long)]
31+
#[clap(help("Whether the mod loader should be checked for this mod"))]
32+
dont_check_mod_loader: bool,
2733
},
2834
#[clap(about("Add a GitHub repository to the profile"))]
2935
AddGithub {
3036
#[clap(help("The repository owner's username"))]
3137
owner: String,
3238
#[clap(help("The name of the repository"))]
3339
name: String,
40+
#[clap(long)]
41+
#[clap(help("Whether the game version should be checked for this mod"))]
42+
dont_check_game_version: bool,
43+
#[clap(long)]
44+
#[clap(help("Whether the mod loader should be checked for this mod"))]
45+
dont_check_mod_loader: bool,
3446
},
3547
#[clap(about("Add a CurseForge mod to the profile"))]
3648
AddCurseforge {
3749
#[clap(help("The project ID is specified at the right sidebar under 'About Project'"))]
3850
project_id: i32,
51+
#[clap(long)]
52+
#[clap(help("Whether the game version should be checked for this mod"))]
53+
dont_check_game_version: bool,
54+
#[clap(long)]
55+
#[clap(help("Whether the mod loader should be checked for this mod"))]
56+
dont_check_mod_loader: bool,
3957
},
4058
#[clap(about("List all the mods in the profile, and with some their metadata if verbose"))]
4159
List {

src/main.rs

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,49 @@ async fn actual_main() -> Result<()> {
107107

108108
// Run function(s) based on the sub(sub)command to be executed
109109
match cli_app.subcommand {
110-
SubCommands::AddModrinth { project_id } => {
111-
add::modrinth(&modrinth, profile, &project_id).await?;
110+
SubCommands::AddModrinth {
111+
project_id,
112+
dont_check_game_version,
113+
dont_check_mod_loader,
114+
} => {
115+
add::modrinth(
116+
&modrinth,
117+
&project_id,
118+
profile,
119+
Some(!dont_check_game_version),
120+
Some(!dont_check_mod_loader),
121+
)
122+
.await?;
112123
},
113-
SubCommands::AddGithub { owner, name } => {
124+
SubCommands::AddGithub {
125+
owner,
126+
name,
127+
dont_check_game_version,
128+
dont_check_mod_loader,
129+
} => {
114130
eprint!("Adding mod... ");
115-
let repo = libium::add::github(github.repos(owner, name), profile).await?;
131+
let repo = libium::add::github(
132+
github.repos(owner, name),
133+
profile,
134+
Some(!dont_check_game_version),
135+
Some(!dont_check_mod_loader),
136+
)
137+
.await?;
116138
println!("{} ({})", *TICK, repo.name);
117139
},
118-
SubCommands::AddCurseforge { project_id } => {
119-
add::curseforge(&curseforge, profile, project_id).await?;
140+
SubCommands::AddCurseforge {
141+
project_id,
142+
dont_check_game_version,
143+
dont_check_mod_loader,
144+
} => {
145+
add::curseforge(
146+
&curseforge,
147+
project_id,
148+
profile,
149+
Some(!dont_check_game_version),
150+
Some(!dont_check_mod_loader),
151+
)
152+
.await?;
120153
},
121154
SubCommands::List { verbose } => {
122155
check_empty_profile(profile)?;

src/subcommands/add.rs

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,49 @@ use dialoguer::Confirm;
44
use ferinth::structures::version_structs::DependencyType;
55
use ferinth::Ferinth;
66
use furse::{structures::file_structs::FileRelationType, Furse};
7-
use libium::{add, config};
7+
use libium::{add, config, upgrade};
88

99
pub async fn modrinth(
1010
modrinth: &Ferinth,
11-
profile: &mut config::structs::Profile,
1211
project_id: &str,
12+
profile: &mut config::structs::Profile,
13+
should_check_game_version: Option<bool>,
14+
should_check_mod_loader: Option<bool>,
1315
) -> Result<()> {
1416
eprint!("Adding mod... ");
15-
let project = add::modrinth(modrinth, project_id, profile).await?;
17+
let project = add::modrinth(
18+
modrinth,
19+
project_id,
20+
profile,
21+
should_check_game_version,
22+
should_check_mod_loader,
23+
)
24+
.await?;
1625
// Add dependencies
17-
let latest_version = libium::upgrade::modrinth(
26+
let result = upgrade::modrinth(
1827
modrinth,
1928
&project.id,
2029
&profile.game_version,
2130
&profile.mod_loader,
22-
Some(true),
23-
Some(true),
31+
should_check_game_version,
32+
should_check_mod_loader,
2433
)
25-
.await?;
34+
.await;
35+
let latest_version = if matches!(result, Err(upgrade::Error::NoCompatibleFile))
36+
&& profile.mod_loader == config::structs::ModLoader::Quilt
37+
{
38+
upgrade::modrinth(
39+
modrinth,
40+
&project.id,
41+
&profile.game_version,
42+
&config::structs::ModLoader::Fabric,
43+
should_check_game_version,
44+
should_check_mod_loader,
45+
)
46+
.await
47+
} else {
48+
result
49+
}?;
2650
println!("{} ({})", *TICK, project.title);
2751
for dependency in latest_version.dependencies {
2852
let id = if let Some(project_id) = dependency.project_id {
@@ -39,7 +63,7 @@ pub async fn modrinth(
3963
// If it's required, add it without asking
4064
if dependency.dependency_type == DependencyType::Required {
4165
eprint!("Adding required dependency... ");
42-
let project = add::modrinth(modrinth, &id, profile).await?;
66+
let project = add::modrinth(modrinth, &id, profile, None, None).await?;
4367
println!("{} ({})", *TICK, project.title);
4468
} else if dependency.dependency_type == DependencyType::Optional {
4569
let project = modrinth.get_project(&id).await?;
@@ -51,7 +75,7 @@ pub async fn modrinth(
5175
.interact()?;
5276
if should_add {
5377
eprint!("Adding optional dependency... ");
54-
let project = add::modrinth(modrinth, &id, profile).await?;
78+
let project = add::modrinth(modrinth, &id, profile, None, None).await?;
5579
println!("{} ({})", *TICK, project.title);
5680
}
5781
}
@@ -63,21 +87,45 @@ pub async fn modrinth(
6387

6488
pub async fn curseforge(
6589
curseforge: &Furse,
66-
profile: &mut config::structs::Profile,
6790
project_id: i32,
91+
profile: &mut config::structs::Profile,
92+
should_check_game_version: Option<bool>,
93+
should_check_mod_loader: Option<bool>,
6894
) -> Result<()> {
6995
eprint!("Adding mod... ");
70-
let project = add::curseforge(curseforge, project_id, profile).await?;
96+
let project = add::curseforge(
97+
curseforge,
98+
project_id,
99+
profile,
100+
should_check_game_version,
101+
should_check_mod_loader,
102+
)
103+
.await?;
71104
// Add dependencies
72-
let latest_version = libium::upgrade::curseforge(
105+
let result = upgrade::curseforge(
73106
curseforge,
74107
project.id,
75108
&profile.game_version,
76109
&profile.mod_loader,
77-
Some(true),
78-
Some(true),
110+
should_check_game_version,
111+
should_check_mod_loader,
79112
)
80-
.await?;
113+
.await;
114+
let latest_version = if matches!(result, Err(upgrade::Error::NoCompatibleFile))
115+
&& profile.mod_loader == config::structs::ModLoader::Quilt
116+
{
117+
upgrade::curseforge(
118+
curseforge,
119+
project.id,
120+
&profile.game_version,
121+
&config::structs::ModLoader::Fabric,
122+
should_check_game_version,
123+
should_check_mod_loader,
124+
)
125+
.await
126+
} else {
127+
result
128+
}?;
81129
println!("{} ({})", *TICK, project.name);
82130
for dependency in latest_version.dependencies {
83131
let id = dependency.mod_id;
@@ -90,7 +138,7 @@ pub async fn curseforge(
90138
// If it's required, add it without asking
91139
if dependency.relation_type == FileRelationType::RequiredDependency {
92140
eprint!("Adding required dependency... ");
93-
let project = add::curseforge(curseforge, id, profile).await?;
141+
let project = add::curseforge(curseforge, id, profile, None, None).await?;
94142
println!("{} ({})", *TICK, project.name);
95143
} else if dependency.relation_type == FileRelationType::OptionalDependency {
96144
let project = curseforge.get_mod(id).await?;
@@ -102,7 +150,7 @@ pub async fn curseforge(
102150
.interact()?;
103151
if should_add {
104152
eprint!("Adding optional dependency... ");
105-
let project = add::curseforge(curseforge, id, profile).await?;
153+
let project = add::curseforge(curseforge, id, profile, None, None).await?;
106154
println!("{} ({})", *TICK, project.name);
107155
}
108156
}

0 commit comments

Comments
 (0)