rusty_cli/inputs/
password_input.rs

1use dialoguer::Password;
2
3pub struct PasswordInput {}
4
5impl PasswordInput {
6
7    /// Gets the value out of a password field
8    pub fn get_value(prompt: Option<String>, reenter: bool) -> Option<String> {
9        let mut input = Password::new();
10        if prompt.is_some() {
11            input.with_prompt(prompt.unwrap());
12        }
13        if reenter {
14            input.with_confirmation("Enter again", "Passwords are not the same");
15        }
16        let interaction_result = input.interact();
17        if interaction_result.is_err() {
18            return None;
19        }
20        Some(interaction_result.unwrap())
21    }
22}