cli: use credentials manager for pakker add
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4cc0075949f12672b4a68f355ca548a96a6a6964
This commit is contained in:
parent
5c5b37b70d
commit
a84a654841
2 changed files with 10 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
|||
|
||||
use crate::{
|
||||
error::{MultiError, PakkerError, Result},
|
||||
model::{Config, LockFile, Project},
|
||||
model::{Config, LockFile, Project, credentials::ResolvedCredentials},
|
||||
platform::create_platform,
|
||||
resolver::DependencyResolver,
|
||||
};
|
||||
|
|
@ -15,7 +15,9 @@ pub fn create_all_platforms()
|
|||
-> HashMap<String, Box<dyn crate::platform::PlatformClient>> {
|
||||
let mut platforms = HashMap::new();
|
||||
|
||||
let curseforge_key = std::env::var("CURSEFORGE_API_KEY").ok();
|
||||
let credentials = ResolvedCredentials::load();
|
||||
let curseforge_key = credentials.curseforge_api_key().map(String::from);
|
||||
|
||||
if let Ok(platform) = create_platform("multiplatform", curseforge_key) {
|
||||
platforms.insert("multiplatform".to_owned(), platform);
|
||||
} else if let Ok(platform) = create_platform("modrinth", None) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use crate::{
|
|||
Config,
|
||||
LockFile,
|
||||
Project,
|
||||
credentials::ResolvedCredentials,
|
||||
enums::{ProjectSide, ProjectType, UpdateStrategy},
|
||||
},
|
||||
platform::create_platform,
|
||||
|
|
@ -315,15 +316,16 @@ fn create_all_platforms()
|
|||
-> HashMap<String, Box<dyn crate::platform::PlatformClient>> {
|
||||
let mut platforms = HashMap::new();
|
||||
|
||||
let curseforge_key = std::env::var("CURSEFORGE_API_KEY").ok();
|
||||
let credentials = ResolvedCredentials::load();
|
||||
let curseforge_key = credentials.curseforge_api_key().map(String::from);
|
||||
let github_token = credentials.github_access_token().map(String::from);
|
||||
|
||||
if let Ok(platform) = create_platform("multiplatform", curseforge_key) {
|
||||
platforms.insert("multiplatform".to_string(), platform);
|
||||
} else if let Ok(platform) = create_platform("modrinth", None) {
|
||||
platforms.insert("modrinth".to_string(), platform);
|
||||
}
|
||||
if let Ok(platform) =
|
||||
create_platform("github", std::env::var("GITHUB_TOKEN").ok())
|
||||
{
|
||||
if let Ok(platform) = create_platform("github", github_token) {
|
||||
platforms.insert("github".to_string(), platform);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue