Skip to content

Commit e344d36

Browse files
Add GitHub PATs to command and tests
1 parent c539f09 commit e344d36

File tree

6 files changed

+23
-4
lines changed

6 files changed

+23
-4
lines changed

CHANGELOG.md

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

3+
## `v3.22.1`
4+
### 25.04.2022
5+
6+
- Add a GitHub personal access token option to the root command
7+
- The integration tests will use the `GITHUB_TOKEN` environment variable if it is available (e.g. during actions workflows)
8+
39
## `v3.22.0`
410
### 24.04.2022
511

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ferium"
3-
version = "3.22.0"
3+
version = "3.22.1"
44
edition = "2021"
55
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"

src/cli.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ pub struct Ferium {
1111
#[clap(subcommand)]
1212
pub subcommand: SubCommands,
1313
#[clap(long)]
14+
#[clap(help("A GitHub personal access token for increasing the rate limit"))]
15+
pub github_token: Option<String>,
16+
#[clap(long)]
1417
#[clap(hide = true)]
15-
#[clap(help("Nur zum testen"))]
18+
#[clap(help("Only for testing"))]
1619
pub config_file: Option<PathBuf>,
1720
}
1821

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ async fn actual_main() -> Result<()> {
7676
}
7777
};
7878

79-
let github = octocrab::instance();
79+
let github = {
80+
let mut builder = octocrab::OctocrabBuilder::new();
81+
if let Some(token) = cli_app.github_token {
82+
builder = builder.personal_token(token.into());
83+
}
84+
octocrab::initialise(builder)
85+
}?;
8086
let modrinth = Ferinth::new();
8187
let curseforge = Furse::new(env!(
8288
"CURSEFORGE_API_KEY",

tests/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ pub fn run_command(args: Vec<&str>, config_file: Option<&str>) -> Result<()> {
1212
}
1313

1414
let mut command = Command::new(env!("CARGO_BIN_EXE_ferium"));
15+
if let Some(token) = option_env!("GITHUB_TOKEN") {
16+
command.arg("--github-token");
17+
command.arg(token);
18+
}
1519
command.args(
1620
// Prepend the config file path to the arguments
1721
// If none is given, provide a config file which doesn't exist

0 commit comments

Comments
 (0)