Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
This commit is contained in:
18
vendor/dialoguer/examples/password.rs
vendored
Normal file
18
vendor/dialoguer/examples/password.rs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
use dialoguer::{theme::ColorfulTheme, Password};
|
||||
|
||||
fn main() {
|
||||
let password = Password::with_theme(&ColorfulTheme::default())
|
||||
.with_prompt("Password")
|
||||
.with_confirmation("Repeat password", "Error: the passwords don't match.")
|
||||
.validate_with(|input: &String| -> Result<(), &str> {
|
||||
if input.len() > 3 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Password must be longer than 3")
|
||||
}
|
||||
})
|
||||
.interact()
|
||||
.unwrap();
|
||||
|
||||
println!("Your password is {} characters long", password.len());
|
||||
}
|
||||
Reference in New Issue
Block a user