Skip to content

Commit

Permalink
Add GitHub PATs to command and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
theRookieCoder committed Apr 25, 2022
1 parent c539f09 commit e344d36
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for Ferium

## `v3.22.1`
### 25.04.2022

- Add a GitHub personal access token option to the root command
- The integration tests will use the `GITHUB_TOKEN` environment variable if it is available (e.g. during actions workflows)

## `v3.22.0`
### 24.04.2022

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.22.0"
version = "3.22.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
5 changes: 4 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ pub struct Ferium {
#[clap(subcommand)]
pub subcommand: SubCommands,
#[clap(long)]
#[clap(help("A GitHub personal access token for increasing the rate limit"))]
pub github_token: Option<String>,
#[clap(long)]
#[clap(hide = true)]
#[clap(help("Nur zum testen"))]
#[clap(help("Only for testing"))]
pub config_file: Option<PathBuf>,
}

Expand Down
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ async fn actual_main() -> Result<()> {
}
};

let github = octocrab::instance();
let github = {
let mut builder = octocrab::OctocrabBuilder::new();
if let Some(token) = cli_app.github_token {
builder = builder.personal_token(token.into());
}
octocrab::initialise(builder)
}?;
let modrinth = Ferinth::new();
let curseforge = Furse::new(env!(
"CURSEFORGE_API_KEY",
Expand Down
4 changes: 4 additions & 0 deletions tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pub fn run_command(args: Vec<&str>, config_file: Option<&str>) -> Result<()> {
}

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

0 comments on commit e344d36

Please sign in to comment.