Skip to content

Commit

Permalink
General small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelmello committed Oct 31, 2022
1 parent f8f235a commit afdf523
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
6 changes: 4 additions & 2 deletions examples/password_simple.rs
@@ -1,7 +1,9 @@
use inquire::Password;
use inquire::{Password, PasswordDisplayMode};

fn main() {
let name = Password::new("RSA Encryption Key:").prompt();
let name = Password::new("RSA Encryption Key:")
.with_display_mode(PasswordDisplayMode::Masked)
.prompt();

match name {
Ok(_) => println!("This doesn't look like a key."),
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -65,7 +65,7 @@

#![warn(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]

#![allow(clippy::bool_to_int_with_if)]
pub mod autocompletion;
mod config;
#[cfg(feature = "date")]
Expand Down
2 changes: 1 addition & 1 deletion src/list_option.rs
Expand Up @@ -5,7 +5,7 @@ use std::fmt::{self, Display};

/// Represents a selection made by the user when prompted to select one or several
/// options among those presented.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ListOption<T> {
/// Index of the selected option relative to the original (full) list passed to the prompt.
pub index: usize,
Expand Down
13 changes: 7 additions & 6 deletions src/prompts/password.rs
Expand Up @@ -309,12 +309,12 @@ impl<'a> From<Password<'a>> for PasswordPrompt<'a> {
message: so.custom_confirmation_message.unwrap_or("Confirmation:"),
error_message: so
.custom_confirmation_error_message
.unwrap_or("The passwords don't match."),
.unwrap_or("THe answers don't match."),
input: Input::new(),
});

Self {
message: so.message.into(),
message: so.message,
help_message: so.help_message,
standard_display_mode: so.display_mode,
display_mode: so.display_mode,
Expand Down Expand Up @@ -510,10 +510,11 @@ impl<'a> PasswordPrompt<'a> {
cancel_prompt!(backend, self.message);
}
}
Key::Submit => match self.handle_submit()? {
Some(answer) => break answer,
None => {}
},
Key::Submit => {
if let Some(answer) = self.handle_submit()? {
break answer;
}
}
key => self.on_change(key),
}
};
Expand Down

0 comments on commit afdf523

Please sign in to comment.