2026-04-01 20:44:05 -04:00
|
|
|
use crate::_legacy::AgeKeySource;
|
2026-03-31 17:26:10 -04:00
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
|
|
pub struct PromptSource;
|
|
|
|
|
|
|
|
|
|
impl AgeKeySource for PromptSource {
|
2026-04-01 20:44:05 -04:00
|
|
|
fn name(&self) -> &str {
|
|
|
|
|
"prompt"
|
|
|
|
|
}
|
2026-03-31 17:26:10 -04:00
|
|
|
|
|
|
|
|
fn retrieve(&self) -> Result<String> {
|
|
|
|
|
let key = rpassword::prompt_password("Paste your age private key: ")
|
|
|
|
|
.map_err(|e| anyhow::anyhow!("could not read age key from prompt: {e}"))?;
|
|
|
|
|
if key.trim().is_empty() {
|
|
|
|
|
anyhow::bail!("empty age key entered");
|
|
|
|
|
}
|
|
|
|
|
Ok(key)
|
|
|
|
|
}
|
|
|
|
|
}
|