cli: prompt for missing CurseForge credentials on add

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Id0bbdc9ed62bc8b9582ccb89158e53786a6a6964
This commit is contained in:
raf 2026-05-01 23:33:42 +03:00
commit e7c6da593d
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 101 additions and 3 deletions

View file

@ -11,6 +11,7 @@ use crate::{
},
platform::create_platform,
resolver::DependencyResolver,
ui_utils::prompt_curseforge_api_key,
};
/// Parse a common project argument (slug or ID with optional file ID)
@ -100,7 +101,16 @@ pub async fn execute(
log::info!("Fetching from CurseForge: {cf_input}");
let (input, file_id) = parse_common_arg(&cf_input);
let cf_api_key = std::env::var("CURSEFORGE_API_KEY").ok();
let credentials = ResolvedCredentials::load();
let mut cf_api_key = credentials.curseforge_api_key().map(String::from);
// Prompt for missing CurseForge credentials
if cf_api_key.is_none() && !yes {
if let Some(key) = prompt_curseforge_api_key(false)? {
cf_api_key = Some(key);
}
}
let platform = create_platform("curseforge", cf_api_key)?;
let mut project = platform