progress: Detect tty with std::io::IsTerminal, remove atty

Fixes https://github.com/advisories/GHSA-g98v-hv3f-hcfr.
This commit is contained in:
Zhaofeng Li 2024-11-08 11:44:10 -07:00
parent 936ed520eb
commit e73c6921fd
3 changed files with 3 additions and 3 deletions

1
Cargo.lock generated
View file

@ -234,7 +234,6 @@ version = "0.5.0-pre"
dependencies = [ dependencies = [
"async-stream", "async-stream",
"async-trait", "async-trait",
"atty",
"clap", "clap",
"clap_complete", "clap_complete",
"clicolors-control", "clicolors-control",

View file

@ -9,7 +9,6 @@ edition = "2021"
[dependencies] [dependencies]
async-stream = "0.3.5" async-stream = "0.3.5"
async-trait = "0.1.68" async-trait = "0.1.68"
atty = "0.2"
clap = { version = "4.3", features = ["derive"] } clap = { version = "4.3", features = ["derive"] }
clap_complete = "4.3" clap_complete = "4.3"
clicolors-control = "1" clicolors-control = "1"

View file

@ -7,6 +7,8 @@
pub mod plain; pub mod plain;
pub mod spinner; pub mod spinner;
use std::io::IsTerminal;
use async_trait::async_trait; use async_trait::async_trait;
use tokio::sync::mpsc::{self, UnboundedReceiver as TokioReceiver, UnboundedSender as TokioSender}; use tokio::sync::mpsc::{self, UnboundedReceiver as TokioReceiver, UnboundedSender as TokioSender};
@ -90,7 +92,7 @@ pub enum LineStyle {
impl SimpleProgressOutput { impl SimpleProgressOutput {
pub fn new(verbose: bool) -> Self { pub fn new(verbose: bool) -> Self {
let tty = atty::is(atty::Stream::Stdout); let tty = std::io::stdout().is_terminal();
if verbose || !tty { if verbose || !tty {
Self::Plain(PlainOutput::new()) Self::Plain(PlainOutput::new())