Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use std's is_terminal() #8

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "4.0.0"
edition = "2021"
authors = ["Jens Reimann <[email protected]>", "Harald Hoyer <[email protected]>"]
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"
Expand All @@ -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"] }
serde = { version = "1", features = ["derive"] }
7 changes: 3 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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(),
}
}

Expand Down