yapp

Crates.ioyapp
lib.rsyapp
version
sourcesrc
created_at2024-03-24 23:41:56.547039+00
updated_at2025-03-02 16:25:24.537857+00
descriptionYet Another Password Prompt
homepage
repositoryhttps://github.com/caleb9/yapp
max_upload_size
id1184820
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Piotr KarasiƄski (Caleb9)

documentation

README

YAPP

Crates.io Version

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.

Features

  • Reads user passwords from the input, optionally with a prompt and echoing replacement symbols (*, or another of your choice).
  • Reads passwords interactively:
    cargo run --example simple
    
  • Reads passwords non-interactively:
    echo "P@55w0rd\n" | cargo run --example simple
    
  • Using the PasswordReader (optionally PasswordReader + IsInteractive) trait in your code allows for mocking the entire library in tests (see an example1 and example2)
  • Thanks to using the console library underneath, it handles unicode correctly (tested on Windows and Linux).

Usage Example

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.

Commit count: 13

cargo fmt