You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
668 B
Rust

use nu_plugin::{EvaluatedCall, LabeledError};
use nu_protocol::Value;
use crate::{prompt::UserPrompt, DialogPlugin};
impl DialogPlugin {
pub(crate) fn password(
&self,
call: &EvaluatedCall,
_input: &Value,
) -> Result<Value, LabeledError> {
let mut pw_input = dialoguer::Password::with_theme(&*self.theme);
pw_input.allow_empty_password(call.has_flag("allow-empty"));
if call.has_flag("confirm") {
pw_input.with_confirmation("Repeat your input", "Error: The inputs don't match");
}
let password = pw_input.ask(call.head)?;
Ok(Value::string(password, call.head))
}
}