From 58ca0e8db5f20848927e0dcb629fc478919081b6 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 9 Jun 2023 14:46:35 +0200 Subject: [PATCH] Replace atty with std --- Cargo.lock | 1 - cli/Cargo.toml | 1 - cli/src/main.rs | 7 +++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba62d6b76..e0193a88e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2398,7 +2398,6 @@ dependencies = [ name = "typst-cli" version = "0.4.0" dependencies = [ - "atty", "chrono", "clap 4.2.7", "clap_complete", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0a1eb7d12..5b29253fd 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -22,7 +22,6 @@ doc = false [dependencies] typst = { path = ".." } typst-library = { path = "../library" } -atty = "0.2" chrono = { version = "0.4.24", default-features = false, features = ["clock", "std"] } clap = { version = "4.2.4", features = ["derive", "env"] } codespan-reporting = "0.11" diff --git a/cli/src/main.rs b/cli/src/main.rs index 17817655a..d4fdfcf06 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -5,11 +5,10 @@ use std::cell::{Cell, RefCell, RefMut}; use std::collections::HashMap; use std::fs::{self, File}; use std::hash::Hash; -use std::io::{self, Write}; +use std::io::{self, IsTerminal, Write}; use std::path::{Path, PathBuf}; use std::process::ExitCode; -use atty::Stream; use chrono::Datelike; use clap::Parser; use codespan_reporting::diagnostic::{Diagnostic, Label}; @@ -368,7 +367,7 @@ fn status(command: &CompileSettings, status: Status) -> io::Result<()> { let color = status.color(); let mut w = color_stream(); - if atty::is(Stream::Stderr) { + if std::io::stderr().is_terminal() { // Clear the terminal. write!(w, "{esc}c{esc}[1;1H")?; } @@ -392,7 +391,7 @@ fn status(command: &CompileSettings, status: Status) -> io::Result<()> { /// Get stderr with color support if desirable. fn color_stream() -> termcolor::StandardStream { - termcolor::StandardStream::stderr(if atty::is(Stream::Stderr) { + termcolor::StandardStream::stderr(if std::io::stderr().is_terminal() { ColorChoice::Auto } else { ColorChoice::Never