use plume_core::auth::Account;
use plume_core::developer::DeveloperSession;
use plume_store::AccountStore;
use omnisette::AnisetteConfiguration;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store_path = Some(PathBuf::from("accounts.json"));
let mut store = AccountStore::load(&store_path).await?;
// Check if we have a stored account
if let Some(gsa_account) = store.selected_account() {
println!("Using stored account: {}", gsa_account.email());
// Create session from stored credentials
let session = DeveloperSession::new(
gsa_account.adsid().clone(),
gsa_account.xcode_gs_token().clone(),
AnisetteConfiguration::default()
).await?;
println!("Session created successfully");
} else {
// No stored account, need to authenticate
println!("No stored account, logging in...");
let account = Account::login(
|| Ok(("[email protected]".to_string(), "password".to_string())),
|| Ok("123456".to_string()),
AnisetteConfiguration::default()
).await?;
// Store the authenticated account
store.accounts_add_from_session(
"[email protected]".to_string(),
account
).await?;
println!("Account stored for future use");
}
Ok(())
}