Replace atty with std

This commit is contained in:
Laurenz 2023-06-09 14:46:35 +02:00
parent 635ef03273
commit 58ca0e8db5
3 changed files with 3 additions and 6 deletions

1
Cargo.lock generated
View File

@ -2398,7 +2398,6 @@ dependencies = [
name = "typst-cli" name = "typst-cli"
version = "0.4.0" version = "0.4.0"
dependencies = [ dependencies = [
"atty",
"chrono", "chrono",
"clap 4.2.7", "clap 4.2.7",
"clap_complete", "clap_complete",

View File

@ -22,7 +22,6 @@ doc = false
[dependencies] [dependencies]
typst = { path = ".." } typst = { path = ".." }
typst-library = { path = "../library" } typst-library = { path = "../library" }
atty = "0.2"
chrono = { version = "0.4.24", default-features = false, features = ["clock", "std"] } chrono = { version = "0.4.24", default-features = false, features = ["clock", "std"] }
clap = { version = "4.2.4", features = ["derive", "env"] } clap = { version = "4.2.4", features = ["derive", "env"] }
codespan-reporting = "0.11" codespan-reporting = "0.11"

View File

@ -5,11 +5,10 @@ use std::cell::{Cell, RefCell, RefMut};
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::{self, File}; use std::fs::{self, File};
use std::hash::Hash; use std::hash::Hash;
use std::io::{self, Write}; use std::io::{self, IsTerminal, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::ExitCode; use std::process::ExitCode;
use atty::Stream;
use chrono::Datelike; use chrono::Datelike;
use clap::Parser; use clap::Parser;
use codespan_reporting::diagnostic::{Diagnostic, Label}; use codespan_reporting::diagnostic::{Diagnostic, Label};
@ -368,7 +367,7 @@ fn status(command: &CompileSettings, status: Status) -> io::Result<()> {
let color = status.color(); let color = status.color();
let mut w = color_stream(); let mut w = color_stream();
if atty::is(Stream::Stderr) { if std::io::stderr().is_terminal() {
// Clear the terminal. // Clear the terminal.
write!(w, "{esc}c{esc}[1;1H")?; 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. /// Get stderr with color support if desirable.
fn color_stream() -> termcolor::StandardStream { fn color_stream() -> termcolor::StandardStream {
termcolor::StandardStream::stderr(if atty::is(Stream::Stderr) { termcolor::StandardStream::stderr(if std::io::stderr().is_terminal() {
ColorChoice::Auto ColorChoice::Auto
} else { } else {
ColorChoice::Never ColorChoice::Never