Skip to content

Commit 9752cc2

Browse files
Fix #157 Custom CF API key
1 parent ae29dbc commit 9752cc2

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Remember to use an add-on like [cargo-update](https://crates.io/crates/cargo-upd
7070
7171
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.
7272

73+
You can also set a custom CurseForge API Key using the `CURSEFORGE_API_KEY` environment variable.
74+
7375
### First Startup
7476

7577
You can either have your own set of mods in what is called a 'profile', or install a modpack.

src/main.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ use libium::config::{
1717
};
1818
use octocrab::OctocrabBuilder;
1919
use online::check;
20-
use std::{process::ExitCode, sync::Arc};
20+
use std::{
21+
env::{var, var_os},
22+
process::ExitCode,
23+
sync::Arc,
24+
};
2125
use tokio::{runtime, spawn};
2226

2327
const CROSS: &str = "×";
@@ -71,13 +75,13 @@ async fn actual_main(cli_app: Ferium) -> Result<()> {
7175
// Yes this is a personal API key, but I am allowed to write it in source.
7276
// The reason is the API key is used for tracking usage, it's not for authentication.
7377
// So please don't use this outside of Ferium, although telling you not to is all I can do...
74-
let curseforge = Arc::new(Furse::new(
75-
"$2a$10$QbCxI6f4KxEs50QKwE2piu1t6oOA8ayOw27H9N/eaH3Sdp5NTWwvO",
76-
));
78+
let curseforge = Arc::new(Furse::new(&var("CURSEFORGE_API_KEY").unwrap_or_else(
79+
|_| "$2a$10$QbCxI6f4KxEs50QKwE2piu1t6oOA8ayOw27H9N/eaH3Sdp5NTWwvO".into(),
80+
)));
7781
let mut config_file = config::get_file(
7882
cli_app
7983
.config_file
80-
.or_else(|| std::env::var_os("FERIUM_CONFIG_FILE").map(Into::into))
84+
.or_else(|| var_os("FERIUM_CONFIG_FILE").map(Into::into))
8185
.unwrap_or_else(config::file_path),
8286
)
8387
.await?;

0 commit comments

Comments
 (0)