From 4bddc3690ae09aff9319bbafeceabd433e9d8225 Mon Sep 17 00:00:00 2001 From: Petr Portnov Date: Wed, 15 Nov 2023 00:36:20 +0300 Subject: [PATCH] feat: use `std`'s `is_terminal()` --- Cargo.toml | 4 ++-- src/lib.rs | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 11dd9cb..f75e189 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "4.0.0" edition = "2021" authors = ["Jens Reimann ", "Harald Hoyer "] description = "Colorize JSON, for printing it out on the command line" +rust-version = "1.70.0" homepage = "https://github.com/ctron/colored_json" repository = "https://github.com/ctron/colored_json" @@ -16,10 +17,9 @@ categories = ["command-line-interface", "encoding", "visualization"] license = "EPL-2.0" [dependencies] -is-terminal = "0.4.4" serde = "1" serde_json = "1" yansi = "0.5" [dev-dependencies] -serde = { version = "1", features = ["derive"] } \ No newline at end of file +serde = { version = "1", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs index 3bb4324..d567454 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -125,12 +125,11 @@ //! # } //!``` -use is_terminal::IsTerminal; use serde::Serialize; use serde_json::ser::Formatter; pub use serde_json::ser::{CompactFormatter, PrettyFormatter}; use serde_json::value::Value; -use std::io; +use std::io::{self, IsTerminal}; pub use yansi::{Color, Style}; @@ -763,8 +762,8 @@ pub enum Output { impl ColorMode { fn is_tty(output: Output) -> bool { match output { - Output::StdOut => std::io::stdout().is_terminal(), - Output::StdErr => std::io::stderr().is_terminal(), + Output::StdOut => io::stdout().is_terminal(), + Output::StdErr => io::stderr().is_terminal(), } }