|
|
|
@ -120,11 +120,11 @@ impl Password
|
|
|
|
|
{
|
|
|
|
|
/// Consume into real password
|
|
|
|
|
#[instrument]
|
|
|
|
|
pub fn into_password(self) -> eyre::Result<Option<String>>
|
|
|
|
|
pub fn into_password(self, prompt: impl AsRef<str>) -> eyre::Result<Option<String>>
|
|
|
|
|
{
|
|
|
|
|
Ok(match self {
|
|
|
|
|
Self::No => None,
|
|
|
|
|
Self::Yes => Some(read_password()?),
|
|
|
|
|
Self::Yes => Some(read_password(prompt.as_ref())?),
|
|
|
|
|
Self::Specific(passwd) => Some(passwd),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -132,8 +132,8 @@ impl Password
|
|
|
|
|
|
|
|
|
|
/// Read password from stdin
|
|
|
|
|
#[instrument(err)]
|
|
|
|
|
fn read_password() -> eyre::Result<String>
|
|
|
|
|
fn read_password(prompt: &str) -> eyre::Result<String>
|
|
|
|
|
{
|
|
|
|
|
rpassword::read_password()
|
|
|
|
|
rpassword::prompt_password_stderr(prompt)
|
|
|
|
|
.wrap_err(eyre!("Failed to read password from stdin"))
|
|
|
|
|
}
|
|
|
|
|