| Crates.io | yapp |
| lib.rs | yapp |
| version | 0.5.0 |
| created_at | 2024-03-24 23:41:56.547039+00 |
| updated_at | 2025-03-02 16:25:24.537857+00 |
| description | Yet Another Password Prompt |
| homepage | |
| repository | https://github.com/caleb9/yapp |
| max_upload_size | |
| id | 1184820 |
| size | 28,372 |
Yet Another Password Prompt
yapp is a small library create for Rust based on the
console to provide simple,
testable password prompt for CLI apps.
*, or another of your choice).cargo run --example simple
echo "P@55w0rd\n" | cargo run --example simple
PasswordReader (optionally PasswordReader + IsInteractive) trait in your code allows for mocking the entire
library in tests (see an example1 and
example2)console library underneath, it handles unicode
correctly (tested on Windows and Linux).use yapp::PasswordReader;
fn my_func<P: PasswordReader>(yapp: &mut P) {
let password = yapp.read_password_with_prompt("Type your password: ").unwrap();
println!("You typed: {password}");
}
fn main() {
let mut yapp = yapp::new().with_echo_symbol('*');
my_func(&mut yapp);
}
use yapp::PasswordReader;
fn my_func(yapp: &mut dyn PasswordReader) {
let password = yapp.read_password_with_prompt("Type your password: ").unwrap();
println!("You typed: {password}");
}
fn main() {
let mut yapp = yapp::new().with_echo_symbol('*');
my_func(&mut yapp);
}
See examples for more.