Skip to content

Commit 959b0d1

Browse files
New config format allowing for less loading time
1 parent fa3badc commit 959b0d1

File tree

16 files changed

+310
-316
lines changed

16 files changed

+310
-316
lines changed

CHANGELOG.md

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

3+
## [3.15.0] - 08.03.2022
4+
5+
Switched from make to [just](https://github.com/casey/just)
6+
7+
- Added back the verbose flag to the list command. The verbose version is the same as before, and the non-verbose version lists out all mod names only
8+
- Small edits to the add command to support the new config format
9+
- The list command now uses a more concise method to display lists of developers/categories (hence the new dependency `itertools`)
10+
- Many commands have been converted to work on one project at a time so there are less loops in functions and more in main.rs
11+
- The remove command has been significantly improved and is now much faster due to the new name storing format
12+
- The remove command now also requires argument provided names to be exactly the same
13+
- Simplified delete profile command
14+
-
15+
316
## [3.14.0] - 06.03.2022
417

518
- All print statements in add and upgrade functions have been removed, this means

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "ferium"
3-
version = "3.14.0"
3+
version = "3.15.0"
44
edition = "2021"
5-
authors = ["theRookieCoder <[email protected]>", "Daniel Hauck (SolidTux)"]
5+
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"
77
exclude = ["tests"] # Don't need tests for installing using crates.io
88
repository = "https://github.com/theRookieCoder/ferium"
@@ -11,10 +11,10 @@ readme = "README.md"
1111
license = "MPL-2.0"
1212
keywords = [
1313
"minecraft",
14-
"cli",
1514
"mod-manager",
1615
"modrinth",
17-
"curseforge"
16+
"curseforge",
17+
"github"
1818
]
1919

2020
[dependencies]
@@ -25,6 +25,7 @@ clap = { version = "3", features = ["derive"] }
2525
serde_json = "1"
2626
ansi_term = "0"
2727
dialoguer = "0"
28+
itertools = "0"
2829
thiserror = "1"
2930
ferinth = "2"
3031
libium = "1"

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
[![license badge](https://img.shields.io/github/license/theRookieCoder/ferium?style=for-the-badge)](https://github.com/theRookieCoder/ferium/blob/main/LICENSE.txt)
55
[![copyleft badge](https://img.shields.io/static/v1?label=&message=Copyleft&style=for-the-badge&labelColor=silver&color=silver&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAQAAAC0NkA6AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfjAxYBNgYPa+9oAAAEM0lEQVRYw6WYb0zVVRjHP9wQW7umA0xoKNSC+6bSNkzetKZbaVu19aLpfOGcbcw/S+uNbikuNwMsVyE3XVsro7VEXjS3ylmLxkRtC9crHGjCAv9AATK4CoZye8Hl/J7n/M7v8rvX57w55/lznt/583yf5/xyCEOlrKaSCp6ggCiQYJheLvMHv9HHA1MZ++kmmaZ1UUNZ9g6eo4X7aR3Mtvs0syJzB0U0MR3KgddOsiQTFxsZzdDBTLvFetd0OT5OHo1U+7j9tNJBN4MkgChFVLCS1Sz1aR7jHf5Lv4Yov1hfN8YRKgP1V9LIuGVxhmg6Fwv4XalPcJD8OTe3gA+YVHYXgt3kWato46nQp1jOWWs1eW7Fz5VaLbkZ3cdc6pX9UfeNkvd+a1aRtV3Fle+mLeGWEO/0mT/EWo7SxhBjjNDPKfbxtMPNVjHLKMVa+I0Q1lmG89nDTWdctPGqz80hIT+uAWRaGOqzeJEraQOw2YrzXNqNbJrlnqDFsCeJKZO3uDtnnN+wNq6cCSM74SGtd1wHlfrOkHAyyDPKrk5codIZ1n7DSlAoVF9iKjRq/cVCYZnPmJHsnWF1GcYRobiQf3yA3sr7VPM2cXp9br5Va2k0/EsAy4SixKh6a5LT6rQibGBAyaeV9SohWQabzeBvhUcTaoqPHHhdTKfSOaWk1wx/E8TN4CuhssW6pjnOCF/KiNrOxULWZPgNEbEJF4VKFT2mdbGLpNNJPzVqC9eKkTdbDK4ajy9ngVaPiHuU5AshWWe4VyIsMuwbWTi5Q7sYlYj+TdNbFBHpJZEV8vao8sOjMS8VRh64MkumrRhSh5UQ+T278s+jQdF/1PTGI4yaweNZuHiYF1RsyCiapdFcengyNajgZyP4RBhP8RpDAU42KcxqE30vNK7KYJQpploFY1NgnfmvApYiZxpskLAi6/PFVh454HBRyJ9K5yclvS5hJQggP7YA8vvZzJCi1+m3NKoUYnj8Eg31jSonDFuTTPEju9nIZuq55IP6FvUJ3iF0zjBqApLWOu6FTlp9FCgM90rX9/zpt1Z9z56QLkasatnLRfe8TT5pmHetQqI6RAoesB5A5aIy/s5jrxAl0VmrJHqFvrQuflCwCPM4Jy71s1L0tTA75IPzAyo5ea3D8eg5LORf2mWqnGaXz3Q+b3CcDm6nCtBfqeV5R+xsUyf1mC3eoBLp9qzAcocquN90qRxTW/Fhxk+Hw8o+HvQIOqPU2qkI7SLGeauAmhf8YrygVCepU0HmpkLqLaQ7nz43Ra3VJBknzqpA/SrivofpaduF64n9Kdt83OupJ/YA48ACiolRyRpHovuMd5kKs8PrA+JirjbsvlFBlE9DyP8qXnQ3+eNiblpOc+gfOCc0gGRGpeyzymq7dbLXSmch/q24qIQ1VBKjjMLUT7UheunmIq2qQgmg/wHquM6d9tIV7AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxOS0wMy0yMlQwMTo1NDowNiswMDowMOIizoUAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTktMDMtMjJUMDE6NTQ6MDYrMDA6MDCTf3Y5AAAAAElFTkSuQmCC)](https://en.wikipedia.org/wiki/Copyleft)
66

7-
> Check out Ferium's sister projects [Ferinth](https://github.com/theRookieCoder/ferinth) and [Furse](https://github.com/theRookieCoder/furse), which are Rust libraries to use the Modrinth and CurseForge APIs respectively
7+
> Check out Ferium's sister projects [Ferinth](https://github.com/theRookieCoder/ferinth) and [Furse](https://github.com/theRookieCoder/furse), Rust libraries to use the Modrinth and CurseForge APIs
88
99
Ferium is an easy to use CLI program for managing Minecraft mods from [Modrinth](https://modrinth.com/mods), [CurseForge](https://curseforge.com/minecraft/mc-mods), and [GitHub Releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases). Simply specify the mods you use through the CLI and in just one command, you can download all the mods and update existing ones.
1010

1111
## Feature Requests
1212

13-
If you would like to make a feature request, check the [issues](https://github.com/theRookieCoder/ferium/issues) and the [project](https://github.com/theRookieCoder/ferium/projects/1) to see if the feature has already been added/planned. If not, [create a new issue](https://github.com/theRookieCoder/ferium/issues/new)
13+
If you would like to make a feature request, check the [issues](https://github.com/theRookieCoder/ferium/issues?q=is%3Aissue) to see if the feature has already been added/planned. If not, [create a new issue](https://github.com/theRookieCoder/ferium/issues/new).
1414

1515
## Building from Source or Working with Ferium
1616

17-
Firstly you need the Rust toolchain (`cargo`, `rustup`, etc). You can install these from <https://rust-lang.org>.
17+
> Note; A lot of Ferium's backend is in a seperate project, [Libium](https://github.com/theRookieCoder/libium). You might want to make some edits there for things like the config
18+
19+
Firstly you need the Rust toolchain (`cargo`, `rustup`, etc), you can install these from <https://rust-lang.org>. You'll also need the [Just](https://github.com/casey/just) command runner, its like `make` but better.
20+
1821
If you want to build Ferium without cloning the repo, set the CurseForge API key then run `cargo install ferium`.
19-
To build the project and install it to your Cargo bin directory, clone the project then run `make install`. If you want to install for testing a developement version, use just `make` or `make install-dev`.
20-
If you want to obtain executables for a specific OS, you can run `make build-<OS>` and replace `<OS>` with `mac`, `win`, or `linux`. The produced binaries will be zipped and moved to `out/`.
21-
You can run the tests using `make test`. Don't use `cargo test` because that will interfere with your existing config, and the integration tests do not work when run in parallel. `make test` saves your config, forces tests to run sequentially, then restores your config (whether the tests failed or not).
22+
23+
To build the project and install it to your Cargo binary directory, clone the project then run `just install`. If you want to install for testing a developement version, run `just` or `just install-dev`.
24+
If you want to obtain executables for a specific OS, you can run `just build-<OS>` and replace `<OS>` with `mac`, `win`, or `linux`. The produced binaries will be zipped and moved to `out/`.
25+
26+
You can run integration tests using `just test`. Don't use `cargo test` because that will interfere with your existing config, and the integration tests do not work when run in parallel. `just test` saves your config, forces tests to run sequentially, then restores your config whether the tests failed or not. Yes this is a terrible way to design integration tests and I will be fixing this soon

makefile renamed to justfile

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,33 @@
1-
.SILENT: test
2-
.DEFAULT_GOAL := install-dev
1+
default: install-dev
32

4-
# This builds for macOS Intel and macOS Apple Silicon
3+
# Build for macOS Intel and macOS Apple Silicon
54
build-mac:
6-
make test
7-
# Remove previous builds
85
rm -f out/ferium-macos-x64.zip out/ferium-macos-arm.zip
9-
# Make builds output directory if it doesn't exist
106
mkdir -p out
11-
# Build for targets
127
cargo build --target=x86_64-apple-darwin --release
138
cargo build --target=aarch64-apple-darwin --release
14-
# Zip and move executables to out/
159
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
1610
zip -r out/ferium-macos-arm.zip -j target/aarch64-apple-darwin/release/ferium
1711

18-
# This builds for Windows MSVC
12+
# Build for Windows MSVC
1913
build-win:
20-
# make test
21-
# Remove previous build if there is one
2214
IF EXIST out\ferium-windows-msvc.zip DEL out\ferium-windows-msvc.zip
23-
# Make builds output directory if it doesn't exist
2415
IF NOT EXIST out MKDIR out
25-
# Build for target
2616
cargo build --target=x86_64-pc-windows-msvc --release
27-
# Zip and move executable to out/
2817
PowerShell -Command Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\ferium.exe" -DestinationPath "out\ferium-windows-msvc.zip"
2918

30-
# This builds for GNU Linux and GNU Windows (e.g. cygwin)
19+
# Build for GNU Linux and GNU Windows (e.g. cygwin)
3120
build-linux:
32-
make test
33-
# Remove previous builds
3421
rm -f out/ferium-linux-gnu.zip out/ferium-windows-gnu.zip
35-
# Make builds output directory if it doesn't exist
3622
mkdir -p out
37-
# Build for targets
3823
cargo build --target=x86_64-pc-windows-gnu --release
3924
cargo build --target=x86_64-unknown-linux-gnu --release
40-
# Zip and move executables to out/
4125
zip -r out/ferium-linux-gnu.zip -j target/x86_64-unknown-linux-gnu/release/ferium
4226
zip -r out/ferium-windows-gnu.zip -j target/x86_64-pc-windows-gnu/release/ferium.exe
4327

28+
# Save config file and run integration tests
4429
test:
45-
cargo clippy -- \
30+
@cargo clippy -- \
4631
-D clippy::all \
4732
-D clippy::cargo \
4833
-D clippy::complexity \
@@ -57,14 +42,15 @@ test:
5742
-A clippy::enum-variant-names \
5843
-A clippy::too-many-lines \
5944
-A clippy::single-match-else
60-
python3 tests/scripts/save_config.py
61-
# Don't parallelise the tests
62-
-cargo test -- --test-threads=1
63-
python3 tests/scripts/restore_config.py
45+
@python3 tests/scripts/save_config.py
46+
@-cargo test -- --test-threads=1
47+
@python3 tests/scripts/restore_config.py
6448

49+
# Install Ferium to cargo's binary folder
6550
install:
6651
cargo install --force --path .
6752

53+
# Install Ferium to cargo's binary folder but debug
6854
install-dev:
6955
cargo install --debug --force --path .
7056

src/cli.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ pub enum SubCommands {
3232
#[clap(help("The project ID is specified as 'Project ID' in the 'About Project' sidebar of the mod's CurseForge page"))]
3333
project_id: i32,
3434
},
35-
#[clap(about("List all the mods in the profile with some their metadata"))]
36-
List,
35+
#[clap(about("List all the mods in the profile, and with some their metadata if verbose"))]
36+
List {
37+
#[clap(long, short)]
38+
#[clap(help("Show information about the mod"))]
39+
verbose: bool,
40+
},
3741
#[clap(subcommand_required = true)]
3842
#[clap(about("Create, configure, or remove the current profile"))]
3943
Profile {

src/main.rs

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,25 @@ async fn actual_main() -> Result<()> {
131131
let project = subcommands::add::curseforge(&curseforge, project_id, profile).await?;
132132
println!("Added {}", project.name);
133133
},
134-
SubCommands::List => {
134+
SubCommands::List { verbose } => {
135135
check_empty_profile(profile)?;
136-
subcommands::list::list(&curseforge, &modrinth, &github, profile).await?;
136+
for mod_ in &profile.mods {
137+
if verbose {
138+
match mod_ {
139+
config::structs::Mod::CurseForgeProject { project_id, .. } => {
140+
subcommands::list::curseforge(&curseforge, *project_id).await
141+
},
142+
config::structs::Mod::ModrinthProject { project_id, .. } => {
143+
subcommands::list::modrinth(&modrinth, project_id).await
144+
},
145+
config::structs::Mod::GitHubRepository { full_name, .. } => {
146+
subcommands::list::github(&github, full_name).await
147+
},
148+
}?;
149+
} else {
150+
println!("{}", mod_.name());
151+
}
152+
}
137153
},
138154
SubCommands::Profile { subcommand } => match subcommand {
139155
ProfileSubCommands::Configure {
@@ -160,8 +176,7 @@ async fn actual_main() -> Result<()> {
160176
},
161177
SubCommands::Remove { mod_names } => {
162178
check_empty_profile(profile)?;
163-
subcommands::remove::remove(&curseforge, &modrinth, &github, profile, mod_names)
164-
.await?;
179+
subcommands::remove::remove(profile, mod_names)?;
165180
},
166181
SubCommands::Switch { profile_name } => {
167182
subcommands::switch::switch(&mut config, profile_name)?;
@@ -171,31 +186,39 @@ async fn actual_main() -> Result<()> {
171186
// Empty the mods directory
172187
let _ = remove_dir_all(&profile.output_dir).await;
173188
create_dir_all(&profile.output_dir).await?;
174-
for project_id in &profile.curse_projects {
175-
if let Err(err) = subcommands::upgrade::curseforge(
176-
&curseforge,
177-
profile,
178-
*project_id,
179-
no_patch_check,
180-
)
181-
.await
182-
{
183-
println!("Could not download {} due to {}", project_id, err);
184-
}
185-
}
186-
for project_id in &profile.modrinth_mods {
187-
if let Err(err) =
188-
subcommands::upgrade::modrinth(&modrinth, profile, project_id, no_patch_check)
189-
.await
190-
{
191-
println!("Could not download {} due to {}", project_id, err);
192-
}
193-
}
194-
for repo in &profile.github_repos {
195-
if let Err(err) =
196-
subcommands::upgrade::github(&github.repos(&repo.0, &repo.1), profile).await
197-
{
198-
println!("Could not download {}/{} due to {}", repo.0, repo.1, err);
189+
for mod_ in &profile.mods {
190+
use libium::config::structs::Mod;
191+
if let (Err(err), name) = match mod_ {
192+
Mod::CurseForgeProject { name, project_id } => (
193+
subcommands::upgrade::curseforge(
194+
&curseforge,
195+
profile,
196+
*project_id,
197+
no_patch_check,
198+
)
199+
.await,
200+
name,
201+
),
202+
Mod::ModrinthProject { name, project_id } => (
203+
subcommands::upgrade::modrinth(
204+
&modrinth,
205+
profile,
206+
project_id,
207+
no_patch_check,
208+
)
209+
.await,
210+
name,
211+
),
212+
Mod::GitHubRepository { name, full_name } => (
213+
subcommands::upgrade::github(
214+
&github.repos(&full_name.0, &full_name.1),
215+
profile,
216+
)
217+
.await,
218+
name,
219+
),
220+
} {
221+
println!("Could not download {} due to {}", name, err);
199222
}
200223
}
201224
},
@@ -209,10 +232,7 @@ async fn actual_main() -> Result<()> {
209232

210233
/// Check if `profile` is empty, and if so return an error
211234
fn check_empty_profile(profile: &config::structs::Profile) -> Result<()> {
212-
if profile.github_repos.is_empty()
213-
&& profile.modrinth_mods.is_empty()
214-
&& profile.curse_projects.is_empty()
215-
{
235+
if profile.mods.is_empty() {
216236
Err(Error::EmptyConfigFile)
217237
} else {
218238
Ok(())

0 commit comments

Comments
 (0)