Skip to content

Commit 013533a

Browse files
Make GitHub PAT and CF API key have a global flag and env var
1 parent af9b7c0 commit 013533a

File tree

7 files changed

+59
-42
lines changed

7 files changed

+59
-42
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
commits:
66
paths:
77
- "**.rs"
8-
- "**.yml"
8+
- ".github/workflows/build.yml"
99
- "Cargo.lock"
1010
- "Cargo.toml"
1111
- "justfile"

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ jobs:
5252
5353
The provided binaries are for:
5454
- Linux (x64 linux musl)
55-
- Linux without a GUI file dialogue and libraries
55+
- Linux without a GUI file dialogue
5656
- Linux ARM (aarch64 linux musl)
57-
- Linux ARM without a GUI file dialogue and libraries
57+
- Linux ARM without a GUI file dialogue (works in Termux!)
5858
- macOS Apple Silicon (aarch64 darwin)
5959
- macOS Intel (x64 darwin)
6060
- GNU Windows (x64 windows gnu) (i.e. Cygwin/MinGW)

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
- Fix [#184](https://github.com/gorilla-devs/ferium/issues/184), switch all linux builds to use `musl`
77
- Fix [#134](https://github.com/gorilla-devs/ferium/issues/134), add arm builds for linux
8+
- Make both the GitHub PAT and custom CF API key have a global flag and environment variable
89

910
## `v4.1.11`
1011
### 02.10.2022

README.md

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
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,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAQA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6/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).
8-
> They are Rust wrappers for 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).
8+
> They are Rust wrappers for the official Modrinth and CurseForge APIs respectively
99
1010
Ferium is a fast and feature rich CLI program for downloading and updating 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), and modpacks from [Modrinth](https://modrinth.com/modpacks) and [CurseForge](https://curseforge.com/minecraft/modpacks).
1111
Simply specify the mods or modpacks you use through the CLI, and in just one command you can the download all the mods or the modpack you configured.
1212

1313
## Features
1414

1515
- Download mods from multiple sources, namely [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)
16-
- Download modpacks from multiple sources, namely [Modrinth](https://modrinth.com/modpacks), [CurseForge](https://curseforge.com/minecraft/modpacks)
16+
- Download modpacks from multiple sources, namely [Modrinth](https://modrinth.com/modpacks) and [CurseForge](https://curseforge.com/minecraft/modpacks)
1717
- Pleasing and beautiful UI
1818
- Listing mods
1919
![Listing Mods](media/list.png)
@@ -22,7 +22,7 @@ Simply specify the mods or modpacks you use through the CLI, and in just one com
2222
- Upgrading mods/modpacks
2323
![Upgrading Mods/Modpacks](media/upgrade.png)
2424
- [It's super fast](https://www.reddit.com/r/rust/comments/umcu1j/media_ferium_the_cli_minecraft_mod_manager) due to multi-threading for network intensive tasks
25-
- You can configure the maximum number of additional threads using the `--threads` options
25+
- Of course, the real world speed still depends on your internet connection
2626
- Upgrade all your mods in one command, `ferium upgrade`
2727
- Ferium checks that the version being downloaded is the latest one compatible with the chosen mod loader and Minecraft version
2828
- You can configure overrides for mods that are not specified as compatible but still work
@@ -32,18 +32,20 @@ Simply specify the mods or modpacks you use through the CLI, and in just one com
3232
## Installation
3333

3434
Ferium is a compiled, statically linked program that does not require external dependencies.
35-
However, Rust programs in general require `gcc-libs` to be installed on Linux.
36-
On Linux the regular version requires GTK, but the `no-gui` version does not need this.
35+
On Linux, the regular version requires some sort of desktop environment that offers an XDG Desktop Portal. The `nogui` versions do not need this.
3736

3837
Ferium is coming to more package managers soon!
3938
[Tracking Issue](https://github.com/theRookieCoder/ferium/issues/42)
4039

41-
### AUR (Arch Linux)
40+
### Arch User Repository (Arch Linux)
4241

42+
- [GUI](https://aur.archlinux.org/packages/ferium-gui-bin)
43+
- [GUI from Source](https://aur.archlinux.org/packages/ferium-gui-git)
4344
- [No GUI](https://aur.archlinux.org/packages/ferium-bin)
44-
- [No GUI from Source](https://aur.archlinux.org/packages/ferium-git) (installs the Rust toolchain)
45-
- [GUI File Dialogue](https://aur.archlinux.org/packages/ferium-gui-bin) (depends on GTK)
46-
- [GUI File Dialogue from Source](https://aur.archlinux.org/packages/ferium-gui-git) (install the Rust toolchain and depends on GTK)
45+
- [No GUI from Source](https://aur.archlinux.org/packages/ferium-git)
46+
47+
From source builds will install the Rust toolchain.
48+
GUI builds require any XDG compatible desktop environment to be available at runtime.
4749

4850
### Scoop (Windows)
4951

@@ -57,11 +59,15 @@ Available [here](https://pacstall.dev/packages/ferium-bin)
5759

5860
Run `pacstall -I ferium-bin` to install.
5961

62+
### Nix Packages
63+
64+
Available [here](https://search.nixos.org/packages?channel=unstable&show=ferium&query=ferium) in the unstable channel.
65+
6066
### Cargo Install (Cross Platform)
6167

62-
If you have the Rust toolchain installed, you can compile and install Ferium from source by running `cargo install ferium`.
68+
If you have the Rust toolchain installed, you can compile and install ferium from source by running `cargo install ferium`.
6369

64-
Remember to use an add-on like [cargo-update](https://crates.io/crates/cargo-update) to keep Ferium updated to the latest version!
70+
Remember to use an add-on like [cargo-update](https://crates.io/crates/cargo-update) to keep ferium updated to the latest version!
6571

6672
### GitHub Releases (Manual - Cross Platform)
6773

@@ -71,12 +77,12 @@ Remember to use an add-on like [cargo-update](https://crates.io/crates/cargo-upd
7177

7278
## Overview / Help Page
7379

74-
> Note! A lot of Ferium's backend is in a seperate project [Libium](https://github.com/theRookieCoder/libium).
80+
> Note! A lot of ferium's backend is in a seperate project [libium](https://github.com/theRookieCoder/libium).
7581
> It deals with things such as the config, adding mod(pack)s, upgrading, file pickers, etc
7682
7783
Ferium stores profile and modpack information in it's config file. By default it is located at `~/.config/ferium/config.json`, but you can change this in 2 ways. You can set the `FERIUM_CONFIG_FILE` environment variable or set the `--config-file` global command flag, the flag always takes precedence.
7884

79-
You can also set a custom CurseForge API Key using the `CURSEFORGE_API_KEY` environment variable.
85+
You can also set a custom CurseForge API key or GitHub personal access token using the `CURSEFORGE_API_KEY` and `GITHUB_TOKEN` environment variables or the `--curseforge_api_key` and `--github-token` flags respectively. Again, the flags take precedence.
8086

8187
### First Startup
8288

@@ -108,9 +114,9 @@ You can either have your own set of mods in what is called a 'profile', or insta
108114
- For example [Sodium's repository](https://github.com/CaffeineMC/sodium-fabric) has the id `CaffeineMC/sodium-fabric`
109115
- You can find these at the top left part of the repository's page as a big 'owner / name'
110116
- So to add [Sodium](https://github.com/CaffeineMC/sodium-fabric), you should run `ferium add CaffeineMC/sodium-fabric` (again, case-insensitive)
111-
- Note: The GitHub repository has to release JAR files in their Releases for Ferium to download, or else it will refuse to be added
117+
- Note: The GitHub repository has to release JAR files in their Releases for ferium to download, or else it will refuse to be added
112118
- External mods
113-
- If you want to use files that are not downloadable by Ferium, place them in the `user` folder in the output directory. Files here will be copied to the output directory when upgrading
119+
- If you want to use files that are not downloadable by ferium, place them in the `user` folder in the output directory. Files here will be copied to the output directory when upgrading
114120

115121
### Adding Modpacks
116122

@@ -129,25 +135,25 @@ You can either have your own set of mods in what is called a 'profile', or insta
129135

130136
### Upgrading Mods
131137

132-
> If your output directory is not empty when setting it, Ferium will offer to create a backup. Please do so if it contains any files you would like to keep
138+
> If your output directory is not empty when setting it, ferium will offer to create a backup. Please do so if it contains any files you would like to keep
133139
134140
Now after adding all your mods, run `ferium upgrade` to download all of them to your output directory.
135141
This defaults to `.minecraft/mods`, where `.minecraft` is the default Minecraft resources directory. You don't need to worry about this if you play with Mojang's launcher (unless you changed the resources directory).
136142
You can choose to pick a custom output directory during profile creation or [change it later](#profiles).
137143

138-
If Ferium fails to download a mod, it will print it's name in red and give the reason. It will continue downloading the rest of the mods and will exit with an error.
144+
If ferium fails to download a mod, it will print it's name in red and give the reason. It will continue downloading the rest of the mods and will exit with an error.
139145

140-
**WARNING:** _When upgrading, any files not downloaded by Ferium will be moved to the `.old` folder in the output directory_
146+
**WARNING:** _When upgrading, any files not downloaded by ferium will be moved to the `.old` folder in the output directory_
141147

142148
### Upgrading Modpacks
143149

144-
> If your output directory's `mods` and `resourcepacks` sre not empty when setting it, Ferium will offer to create a backup. Please do so if it contains any files you would like to keep
150+
> If your output directory's `mods` and `resourcepacks` sre not empty when setting it, ferium will offer to create a backup. Please do so if it contains any files you would like to keep
145151
146152
Now after adding all your mods, run `ferium modpack upgrade` to download the modpack to your output directory.
147153
This defaults to `.minecraft`, which is the default Minecraft resources directory. You don't need to worry about this if you play with Mojang's launcher (unless you changed the resources directory).
148154
You can choose to pick a custom output directory when adding modpacks or [change it later](#managing-modpacks).
149155

150-
If Ferium fails to download a mod, it will print it's name in red and give the reason. It will continue downloading the rest of the mods and will exit with an error.
156+
If ferium fails to download a mod, it will print it's name in red and give the reason. It will continue downloading the rest of the mods and will exit with an error.
151157

152158
**WARNING:** _If you choose to install modpack overrides, your existing configs may be overwritten_
153159

@@ -160,7 +166,7 @@ You can also provide the names of the mods to remove as arguments. Mod names wit
160166

161167
#### Check Overrides
162168

163-
If some mod is compatible with your profile but Ferium does not download it, [create an issue]((https://github.com/theRookieCoder/ferium/issues/new)) if you think it's a bug. You can disable the game version or mod loader checks by using the `--dont-check-game-version` and/or `--dont-check-mod-loader` flags when adding the mod, or manually setting `check_game_version` or `check_mod_loader` to false for the specific mod in the config.
169+
If some mod is compatible with your profile but ferium does not download it, [create an issue]((https://github.com/theRookieCoder/ferium/issues/new)) if you think it's a bug. You can disable the game version or mod loader checks by using the `--dont-check-game-version` and/or `--dont-check-mod-loader` flags when adding the mod, or manually setting `check_game_version` or `check_mod_loader` to false for the specific mod in the config.
164170

165171
For example, [Just Enough Items](https://www.curseforge.com/minecraft/mc-mods/jei) does not specify the mod loader for older minecraft versions such as `1.12.2`. In this case, you would add JEI by running `ferium add 238222 --dont-check-mod-loader` so that the mod loader check is disabled.
166172
You can also manually disable the mod loader (and/or game version) check(s) in the config like so
@@ -227,7 +233,7 @@ Delete a profile by running `ferium profile delete` and selecting the profile yo
227233

228234
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 or is planned. If not, [create a new issue](https://github.com/theRookieCoder/ferium/issues/new).
229235

230-
## Building from Source or Working on Ferium
236+
## Building from Source or Working on ferium
231237

232238
Firstly, you need the Rust toolchain which includes `cargo`, `rustup`, etc. You can install these from [the Rust website](https://www.rust-lang.org/tools/install).
233239
You'll also need the [`just`](https://github.com/casey/just#installation) command runner, which is basically a much better version of `make`.

src/cli.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ pub struct Ferium {
1616
/// The limit for additional threads spawned by the Tokio runtime
1717
pub threads: Option<usize>,
1818
#[clap(long)]
19-
/// A GitHub personal access token for increasing the GitHub API rate limit
19+
/// Set a GitHub personal access token for increasing the GitHub API rate limit.
20+
/// You can also use the environment variable `GITHUB_TOKEN`
2021
pub github_token: Option<String>,
2122
#[clap(long)]
22-
/// Set the file to read the config from. Does not change the cache and tmp directories
23+
/// Set a custom CurseForge API key.
24+
/// You can also use the environment variable `CURSEFORGE_API_KEY`
25+
pub curseforge_api_key: Option<String>,
26+
#[clap(long)]
2327
#[clap(value_hint(ValueHint::FilePath))]
28+
/// Set the file to read the config from. Does not change the cache and tmp directories
2429
pub config_file: Option<PathBuf>,
2530
}
2631

src/main.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
8484
let github = Arc::new(
8585
cli_app
8686
.github_token
87-
.map_or_else(OctocrabBuilder::new, |token| {
88-
OctocrabBuilder::new().personal_token(token)
89-
})
87+
.map_or_else(
88+
|| {
89+
var("GITHUB_TOKEN").map_or_else(
90+
|_| OctocrabBuilder::new(),
91+
|token| OctocrabBuilder::new().personal_token(token),
92+
)
93+
},
94+
|token| OctocrabBuilder::new().personal_token(token),
95+
)
9096
.build()?,
9197
);
9298
let modrinth = Arc::new(Ferinth::new(
@@ -95,11 +101,12 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
95101
Some("theRookieCoder#1287"),
96102
None,
97103
)?);
98-
// Yes this is a personal API key, but I am allowed to write it in source.
99-
// The reason is the API key is used for tracking usage, it's not for authentication.
100-
// So please don't use this outside of Ferium, although telling you not to is all I can do...
101-
let curseforge = Arc::new(Furse::new(&var("CURSEFORGE_API_KEY").unwrap_or_else(
102-
|_| "$2a$10$QbCxI6f4KxEs50QKwE2piu1t6oOA8ayOw27H9N/eaH3Sdp5NTWwvO".into(),
104+
let curseforge = Arc::new(Furse::new(&cli_app.curseforge_api_key.unwrap_or_else(
105+
|| {
106+
var("CURSEFORGE_API_KEY").unwrap_or_else(|_| {
107+
"$2a$10$QbCxI6f4KxEs50QKwE2piu1t6oOA8ayOw27H9N/eaH3Sdp5NTWwvO".into()
108+
})
109+
},
103110
)));
104111

105112
let mut config_file = config::get_file(
@@ -205,7 +212,9 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
205212
.collect::<Vec<_>>(),
206213
)
207214
.await?;
208-
for (project, team_members) in mr_projects.into_iter().zip(mr_teams_members.into_iter()) {
215+
for (project, team_members) in
216+
mr_projects.into_iter().zip(mr_teams_members.into_iter())
217+
{
209218
tasks.push(spawn(subcommands::list::modrinth(project, team_members)));
210219
}
211220
}

tests/util.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs::{copy, create_dir};
44
use std::io::Result;
55

66
pub fn run_command(args: Vec<&str>, config_file: Option<&str>) -> Result<()> {
7-
let mut args = args; // Borrow checker bug (I think)
7+
let mut args = args;
88
let running = format!("./tests/configs/running/{}.json", rand::random::<u16>());
99
if let Some(config_file) = config_file {
1010
let _ = create_dir("./tests/configs/running");
@@ -14,10 +14,6 @@ pub fn run_command(args: Vec<&str>, config_file: Option<&str>) -> Result<()> {
1414

1515
let mut command = Command::new(env!("CARGO_BIN_EXE_ferium"));
1616
let mut arguments = Vec::new();
17-
if let Some(token) = option_env!("GITHUB_TOKEN") {
18-
arguments.push("--github-token");
19-
arguments.push(token);
20-
}
2117
arguments.push("--config-file");
2218
arguments.push(&running);
2319
arguments.append(&mut args);

0 commit comments

Comments
 (0)