Skip to content

Commit 26f0ea5

Browse files
committed
misc: remove dependency on atty
1 parent ee39c68 commit 26f0ea5

File tree

3 files changed

+4
-48
lines changed

3 files changed

+4
-48
lines changed

Cargo.lock

-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ uint = { version = "0.9", default-features = false }
2828
pbkdf2 = { version = "0.12", default-features = false, features = ["hmac"] }
2929
sha2 = { version = "0.10", default-features = false }
3030

31-
atty = { version = "0.2", optional = true }
3231
clap = { version = "4.0", optional = true, features = ["derive"] }
3332
rpassword = { version = "7.1", optional = true }
3433

3534
[features]
36-
default = [ "atty", "clap", "rpassword", "std" ]
35+
default = [ "clap", "rpassword", "std" ]
3736
std = []

src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clap::{CommandFactory as _, Parser};
22
use lesspass::*;
33

4-
use std::io::Write;
4+
use std::io::{IsTerminal, Write};
55

66
/// Generates LessPass-like passwords.
77
#[derive(Parser)]
@@ -182,7 +182,7 @@ fn run() -> Result<(), &'static str> {
182182
Some(pass) => pass,
183183
None => {
184184
// Get entropy from standard input.
185-
if atty::is(atty::Stream::Stdin) {
185+
if std::io::stdin().is_terminal() {
186186
// Stdin is a terminal, and no one in their right mind would copy
187187
// the entropy by hand, so we cancel early.
188188
return Err("");
@@ -249,7 +249,7 @@ fn print_buffer_hex(buf: &[u8], out: &mut dyn Write) -> Result<(), &'static str>
249249
fn read_password() -> Result<String, &'static str> {
250250
// If the input is passed from Stdin, it fails on my machine,
251251
// so we handle this here
252-
if atty::is(atty::Stream::Stdin) {
252+
if std::io::stdin().is_terminal() {
253253
rpassword::read_password().map_err(|_| "Unable to read password or entropy.")
254254
} else {
255255
let stdin = std::io::stdin();

0 commit comments

Comments
 (0)