Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
theRookieCoder committed Apr 3, 2022
1 parent 7515469 commit 0db8226
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 26 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog for Ferium

## [3.19.1] - 03.04.2022

- Added a sort command that sorts mods in alphabetical order
- Edited the `mod.rs` files to make accessing functions better
- Updated some user facing output such as command help pages, and errors
- Reverted to the old output style in the add command

## [3.19.0] - 02.04.2022

> WARNING!
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ferium"
version = "3.19.0"
version = "3.19.1"
edition = "2021"
authors = ["Ilesh Thiada (theRookieCoder) <[email protected]>", "Daniel Hauck (SolidTux)"]
description = "Ferium is a CLI program for managing Minecraft mods from Modrinth, CurseForge, and Github Releases"
Expand Down
7 changes: 4 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//! Contains convenience wrappers for argument parsing using Clap
#![deny(missing_docs)] // All commands must have help/about statements

use clap::{Parser, Subcommand};
Expand All @@ -21,7 +20,7 @@ pub struct Ferium {
pub enum SubCommands {
#[clap(about("Add a Modrinth mod to the profile"))]
AddModrinth {
#[clap(help("The project ID is specified as '</> PROJECT ID' in the right sidebar of the mod's Modrith page\nYou can also use the project slug for this"))]
#[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"))]
project_id: String,
},
#[clap(about("Add a GitHub repository to the profile"))]
Expand All @@ -33,7 +32,7 @@ pub enum SubCommands {
},
#[clap(about("Add a CurseForge mod to the profile"))]
AddCurseforge {
#[clap(help("The project ID is specified as 'Project ID' in the 'About Project' sidebar of the mod's CurseForge page"))]
#[clap(help("The project ID is specified at the right sidebar under 'About Project'"))]
project_id: i32,
},
#[clap(about("List all the mods in the profile, and with some their metadata if verbose"))]
Expand Down Expand Up @@ -61,6 +60,8 @@ pub enum SubCommands {
#[clap(help("The name of the profile to switch to"))]
profile_name: Option<String>,
},
#[clap(about("Sort all your mods in alphabetical order"))]
Sort,
#[clap(about("Download and install the latest version of the mods specified"))]
Upgrade {
#[clap(long)]
Expand Down
28 changes: 16 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn actual_main() -> Result<()> {
},
} = cli_app.subcommand
{
subcommands::profile::create::create(
subcommands::profile::create(
&modrinth,
&mut config,
game_version,
Expand All @@ -80,7 +80,7 @@ async fn actual_main() -> Result<()> {
)
.await?;

// Update config file with new values and quit
// Update config file and quit
config::write_config(&mut config_file, &config).await?;
return Ok(());
}
Expand All @@ -95,22 +95,25 @@ async fn actual_main() -> Result<()> {
// Default to first profile if index is set incorrectly
config.active_profile = 0;
config::write_config(&mut config_file, &config).await?;
bail!("Active profile index points to a non existent profile. Switched to first profile",)
bail!("Active profile specified incorrectly. Switched to first profile",)
};

// Run function(s) based on the sub(sub)command to be executed
match cli_app.subcommand {
SubCommands::AddModrinth { project_id } => {
eprint!("Adding mod... ");
let project = add::modrinth(&modrinth, project_id, profile).await?;
println!("Added {}", project.title);
println!("{} ({})", *TICK, project.title);
},
SubCommands::AddGithub { owner, name } => {
eprint!("Adding mod... ");
let repo = add::github(github.repos(owner, name), profile).await?;
println!("Added {}", repo.name);
println!("{} ({})", *TICK, repo.name);
},
SubCommands::AddCurseforge { project_id } => {
eprint!("Adding mod... ");
let project = add::curseforge(&curseforge, project_id, profile).await?;
println!("Added {}", project.name);
println!("{} ({})", *TICK, project.name);
},
SubCommands::List { verbose } => {
check_empty_profile(profile)?;
Expand Down Expand Up @@ -140,7 +143,7 @@ async fn actual_main() -> Result<()> {
name,
output_dir,
} => {
subcommands::profile::configure::configure(
subcommands::profile::configure(
profile,
game_version,
mod_loader,
Expand All @@ -149,20 +152,21 @@ async fn actual_main() -> Result<()> {
)
.await?;
},
// This must have been checked earlier before getting the profile
// This must have ran earlier before getting the profile
ProfileSubCommands::Create { .. } => unreachable!(),
ProfileSubCommands::Delete { profile_name } => {
subcommands::profile::delete::delete(&mut config, profile_name)?;
subcommands::profile::delete(&mut config, profile_name)?;
},
ProfileSubCommands::List => subcommands::profile::list::list(&config),
ProfileSubCommands::List => subcommands::profile::list(&config),
},
SubCommands::Remove { mod_names } => {
check_empty_profile(profile)?;
subcommands::remove::remove(profile, mod_names)?;
subcommands::remove(profile, mod_names)?;
},
SubCommands::Switch { profile_name } => {
subcommands::switch::switch(&mut config, profile_name)?;
subcommands::switch(&mut config, profile_name)?;
},
SubCommands::Sort => profile.mods.sort_by_cached_key(|mod_| mod_.name.clone()),
SubCommands::Upgrade { no_patch_check } => {
check_empty_profile(profile)?;
// Empty the mods directory
Expand Down
6 changes: 4 additions & 2 deletions src/subcommands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod list;
pub mod profile;
pub mod remove;
pub mod switch;
mod remove;
mod switch;
pub use remove::remove;
pub use switch::switch;
5 changes: 2 additions & 3 deletions src/subcommands/profile/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub async fn create(
if profile.name == name {
println!("A profile with name {} already exists!", name);
prompt = true;
break;
}
}
}
Expand Down Expand Up @@ -107,10 +108,8 @@ pub async fn create(
mod_loader: selected_loader,
});
},
// Either all or none of these options should exist
// TODO: make this into a group in the Clap app
_ => {
bail!("Provide all four arguments to create a profile using options",)
bail!("Provide all four arguments to create a profile using options")
},
}

Expand Down
12 changes: 8 additions & 4 deletions src/subcommands/profile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pub mod configure;
pub mod create;
pub mod delete;
pub mod list;
mod configure;
mod create;
mod delete;
mod list;
pub use configure::configure;
pub use create::create;
pub use delete::delete;
pub use list::list;

0 comments on commit 0db8226

Please sign in to comment.