use anyhow::Result;
use cleanlib_client::config;
use crate::auth;
pub fn run(also_keyring: bool) -> Result<()> {
let path = config::default_path()
.ok_or_else(|| anyhow::anyhow!("home directory not discoverable"))?;
if !path.exists() {
eprintln!("no config file at {}; nothing to remove there", path.display());
} else {
let mut cfg = config::load(&path)?;
if cfg.auth.api_key.is_none() {
eprintln!("no api key configured in {}; nothing to remove there", path.display());
} else {
cfg.auth.api_key = None;
config::save(&cfg, &path)?;
eprintln!("api key removed from {}", path.display());
}
}
if also_keyring {
auth::bearer::delete_from_keyring()?;
eprintln!("keyring entry removed (service={})", auth::KEYRING_SERVICE);
}
Ok(())
}