Skip to content
Closed
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
4 changes: 2 additions & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
format_code_in_doc_comments = true
enum_discrim_align_threshold = 20
struct_field_align_threshold = 20
# enum_discrim_align_threshold = 20
# struct_field_align_threshold = 20
condense_wildcard_suffixes = true
match_block_trailing_comma = true
normalize_doc_attributes = true
Expand Down
11 changes: 9 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ pub enum SubCommands {
/// The Modrinth project ID is specified at the bottom of the left sidebar under 'Technical information'. You can also use the project slug in the URL.
/// The CurseForge mod ID is specified at the top of the right sidebar under 'About Project'.
/// The GitHub identifier is the repository's full name, e.g. `gorilla-devs/ferium`.
identifier: String,
identifiers: Vec<String>,

#[clap(long)]
/// The game version will not be checked for this mod
dont_check_game_version: bool,
Expand Down Expand Up @@ -66,6 +67,8 @@ pub enum SubCommands {
/// Useful for creating modpack mod lists.
/// Complements the verbose flag.
markdown: bool,
#[clap(long, short)]
export: bool,
},
#[clap(arg_required_else_help = true)]
/// Add, configure, delete, switch, list, or upgrade modpacks
Expand All @@ -87,7 +90,11 @@ pub enum SubCommands {
mod_names: Vec<String>,
},
/// Download and install the latest version of the mods specified
Upgrade,
Upgrade {
#[clap(long, short)]
/// Don’t print compatible mods
less: bool,
},
}

#[derive(Subcommand)]
Expand Down
83 changes: 42 additions & 41 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,52 +113,47 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
match cli_app.subcommand {
SubCommands::Complete { .. } => unreachable!(),
SubCommands::Add {
identifier,
identifiers,
dont_check_game_version,
dont_check_mod_loader,
dependencies,
} => {
let profile = get_active_profile(&mut config)?;
check_internet().await?;
if let Ok(project_id) = identifier.parse::<i32>() {
subcommands::add::curseforge(
let mut error = false;
for identifier in identifiers {
match subcommands::add::add_mod(
identifier,
&curseforge,
project_id,
profile,
Some(!dont_check_game_version),
Some(!dont_check_mod_loader),
dependencies,
)
.await?;
} else if identifier.split('/').count() == 2 {
let split = identifier.split('/').collect::<Vec<_>>();
subcommands::add::github(
github.repos(split[0], split[1]),
&github,
&modrinth,
profile,
Some(!dont_check_game_version),
Some(!dont_check_mod_loader),
dont_check_game_version,
dont_check_mod_loader,
&dependencies,
)
.await?;
} else if let Err(err) = subcommands::add::modrinth(
&modrinth,
&identifier,
profile,
Some(!dont_check_game_version),
Some(!dont_check_mod_loader),
dependencies,
)
.await
{
return Err(
if err.to_string() == ferinth::Error::NotBase62.to_string() {
anyhow!("Invalid indentifier")
} else {
err
.await
{
Ok(_) => {},
Err(e) => {
if e.to_string() == libium::add::Error::AlreadyAdded.to_string() {
println!("{} Already added", *TICK);
} else {
eprintln!("{}", e.to_string().red().bold());
}
error = true;
},
);
}
}
if error {
return Err(anyhow!(""));
}
},
SubCommands::List { verbose, markdown } => {
SubCommands::List {
verbose,
markdown,
export,
} => {
let profile = get_active_profile(&mut config)?;
check_empty_profile(profile)?;
if verbose {
Expand Down Expand Up @@ -216,10 +211,16 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
}
} else {
for mod_ in &profile.mods {
println!(
"{:45} {}",
mod_.name.bold(),
if export {
match &mod_.identifier {
ModIdentifier::CurseForgeProject(id) => println!("{}", id),
ModIdentifier::ModrinthProject(id) => println!("{}", id),
ModIdentifier::GitHubRepository(name) => {
println!("{}/{}", name.0, name.1)
},
}
} else {
println!("{:45} {}", mod_.name.bold(), match &mod_.identifier {
ModIdentifier::CurseForgeProject(id) =>
format!("{:10} {}", "CurseForge".red(), id.to_string().dimmed()),
ModIdentifier::ModrinthProject(id) =>
Expand All @@ -229,8 +230,8 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
"GitHub".purple(),
format!("{}/{}", name.0, name.1).dimmed()
),
},
);
},);
}
}
}
},
Expand Down Expand Up @@ -355,11 +356,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
Loading