mirror of
https://github.com/typst/typst
synced 2025-05-17 02:25:27 +08:00
cli: Emit escape codes only if output is a tty (#1188)
This commit is contained in:
parent
42c3a6fa72
commit
42f1586880
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2276,6 +2276,7 @@ dependencies = [
|
|||||||
name = "typst-cli"
|
name = "typst-cli"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"atty",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap 4.2.5",
|
"clap 4.2.5",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
|
@ -22,6 +22,7 @@ doc = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
typst = { path = ".." }
|
typst = { path = ".." }
|
||||||
typst-library = { path = "../library" }
|
typst-library = { path = "../library" }
|
||||||
|
atty = "0.2"
|
||||||
chrono = { version = "0.4", default-features = false, features = ["clock", "std"] }
|
chrono = { version = "0.4", 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"
|
||||||
|
@ -9,6 +9,7 @@ use std::io::{self, Write};
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
|
use atty::Stream;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use codespan_reporting::diagnostic::{Diagnostic, Label};
|
use codespan_reporting::diagnostic::{Diagnostic, Label};
|
||||||
use codespan_reporting::term::{self, termcolor};
|
use codespan_reporting::term::{self, termcolor};
|
||||||
@ -282,7 +283,9 @@ fn status(command: &CompileSettings, status: Status) -> io::Result<()> {
|
|||||||
let color = status.color();
|
let color = status.color();
|
||||||
|
|
||||||
let mut w = StandardStream::stderr(ColorChoice::Auto);
|
let mut w = StandardStream::stderr(ColorChoice::Auto);
|
||||||
write!(w, "{esc}c{esc}[1;1H")?;
|
if atty::is(Stream::Stderr) {
|
||||||
|
write!(w, "{esc}c{esc}[1;1H")?;
|
||||||
|
}
|
||||||
|
|
||||||
w.set_color(&color)?;
|
w.set_color(&color)?;
|
||||||
write!(w, "watching")?;
|
write!(w, "watching")?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user