https://github.com/caleb9/yapp
Yet Another Password Prompt
https://github.com/caleb9/yapp
cli console password prompt terminal
Last synced: 11 months ago
JSON representation
Yet Another Password Prompt
- Host: GitHub
- URL: https://github.com/caleb9/yapp
- Owner: Caleb9
- License: mit
- Created: 2024-03-24T23:02:45.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-05T12:40:41.000Z (11 months ago)
- Last Synced: 2025-07-19T06:48:42.679Z (11 months ago)
- Topics: cli, console, password, prompt, terminal
- Language: Rust
- Homepage:
- Size: 28.3 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# YAPP
[](https://crates.io/crates/yapp)
Yet Another Password Prompt
`yapp` is a small library create for Rust based on the
[console](https://github.com/console-rs/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:
```bash
cargo run --example simple
```
* Reads passwords non-interactively:
```bash
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](examples/mock_yapp.rs) and
[example2](examples/mock_yapp_with_is_interactive.rs))
* Thanks to using the `console` library underneath, it handles unicode
correctly (tested on Windows and Linux).
## Usage Example
```rust
use yapp::{PasswordReader, Yapp};
fn my_func(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);
}
```
```rust
use yapp::{PasswordReader, Yapp};
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](examples/) for more.