passterm

Crates.iopassterm
lib.rspassterm
version2.0.4
sourcesrc
created_at2021-12-15 05:36:57.613407
updated_at2024-10-28 01:18:21.910663
descriptionRead terminal password, check isatty
homepagehttps://github.com/finfet/passterm
repositoryhttps://github.com/finfet/passterm
max_upload_size
id498065
size31,051
Kyle Schreiber (finfet)

documentation

https://docs.rs/passterm/

README

Terminal Utilities

Provides a way to read passwords from a terminal. Terminal echo is disabled when reading the password.

Also provides the ability to check if a terminal is a tty or not.

This crate provides functionality similar to the python getpass and os.isatty functions.

Tested on Linux, macOS, and Windows.

Functions on windows use the windows api directly without relying on large crates like windows-sys or winapi.

Example: Get a password

use passterm::prompt_password_tty;

let pass = prompt_password_tty(Some("Password: ")).unwrap();

println!("Your password is: {}", &pass);

Example: Check if standard output has been redirected

use passterm::{isatty, Stream};

let is_tty = isatty(Stream::Stdout);
if is_tty {
    println!("We're in a terminal");
} else {
    println!("Not in a terminal. Output was redirected >.");
}
Commit count: 42

cargo fmt