cli: prompt for missing CurseForge credentials on add
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id0bbdc9ed62bc8b9582ccb89158e53786a6a6964
This commit is contained in:
parent
d2d6b7c421
commit
e7c6da593d
2 changed files with 101 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue