Skip to content

Commit 4afceda

Browse files
committed
Migrate away from atty
1 parent 0eb8800 commit 4afceda

File tree

4 files changed

+11
-29
lines changed

4 files changed

+11
-29
lines changed

Cargo.lock

Lines changed: 4 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ repository = "https://github.com/trailofbits/necessist"
1212
[dependencies]
1313
ansi_term = "0.12"
1414
anyhow = "1.0"
15-
atty = "0.2"
1615
bitflags = "2.3"
1716
clap = { version = "4.3", features = ["cargo", "derive"], optional = true }
1817
ctrlc = "3.4"
1918
diesel = { version = "2.1", features = ["sqlite"] }
2019
git2 = "0.17"
2120
heck = "0.4"
2221
indicatif = "0.17"
22+
is-terminal = "0.4"
2323
log = "0.4"
2424
once_cell = "1.18"
2525
proc-macro2 = { version = "1.0", features = ["span-locations"] }

core/src/core.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use ansi_term::Style;
88
use anyhow::{anyhow, bail, ensure, Result};
99
use heck::ToKebabCase;
1010
use indicatif::ProgressBar;
11+
use is_terminal::IsTerminal;
1112
use log::debug;
1213
use std::{
1314
collections::BTreeMap,
@@ -129,7 +130,7 @@ pub fn necessist<Identifier: Applicable + Display + IntoEnumIterator + ToImpleme
129130
}
130131

131132
let progress =
132-
if var("RUST_LOG").is_err() && !context.opts.quiet && atty::is(atty::Stream::Stdout) {
133+
if var("RUST_LOG").is_err() && !context.opts.quiet && std::io::stdout().is_terminal() {
133134
Some(ProgressBar::new(n_spans as u64))
134135
} else {
135136
None
@@ -539,7 +540,7 @@ fn emit_to_console(context: &LightContext, removal: &Removal) {
539540
"{}: `{}` {}",
540541
span.to_console_string(),
541542
text,
542-
if atty::is(atty::Stream::Stdout) {
543+
if std::io::stdout().is_terminal() {
543544
outcome.style().bold()
544545
} else {
545546
Style::default()

core/src/warn.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use ansi_term::{
66
use anyhow::{bail, Result};
77
use bitflags::bitflags;
88
use heck::ToKebabCase;
9+
use is_terminal::IsTerminal;
910
use std::{collections::BTreeMap, sync::Mutex};
1011

1112
// smoelius: `Warning` is part of Necessist's public API. Please try to follow the naming convention
@@ -142,7 +143,7 @@ Silence this warning with: --allow {warning}"
142143
"{}: ",
143144
source.to_console_string()
144145
)),
145-
if atty::is(atty::Stream::Stdout) {
146+
if std::io::stdout().is_terminal() {
146147
Yellow.bold()
147148
} else {
148149
Style::default()
@@ -164,7 +165,7 @@ pub(crate) fn note(context: &LightContext, msg: &str) {
164165

165166
(context.println)(&format!(
166167
"{}: {}",
167-
if atty::is(atty::Stream::Stdout) {
168+
if std::io::stdout().is_terminal() {
168169
Green.bold()
169170
} else {
170171
Style::default()

0 commit comments

Comments
 (0)