Skip to content
Open
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
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords = ["ansi", "terminal", "color", "format", "paint"]
readme = "README.md"
license = "MIT OR Apache-2.0"
categories = ["command-line-interface"]
rust-version = "1.63"
rust-version = "1.85"
edition = "2021"
resolver = "2"

Expand All @@ -18,7 +18,7 @@ all-features = true

[features]
default = ["std"]
detect-tty = ["is-terminal", "std"]
detect-tty = ["std"]
detect-env = ["std"]
hyperlink = ["std"]
std = ["alloc"]
Expand All @@ -28,4 +28,3 @@ alloc = []
_nightly = []

[dependencies]
is-terminal = { version = "0.4.11", optional = true }
22 changes: 10 additions & 12 deletions src/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ use core::sync::atomic::{AtomicPtr, Ordering};
/// `yansi` comes with built-in conditions for common scenarios that can be
/// enabled via crate features:
///
/// | feature(s) | condition | implication |
/// |------------------------------|---------------------------------|------------------------|
/// | `detect-tty` | [TTY Detectors] | `std`, [`is-terminal`] |
/// | `detect-env` | [Environment Variable Checkers] | `std` |
/// | [`detect-tty`, `detect-env`] | All Above, [Combo Detectors] | `std`, [`is-terminal`] |
///
/// [`is-terminal`]: https://docs.rs/is-terminal
/// | feature(s) | condition | implication |
/// |------------------------------|---------------------------------|-------------|
/// | `detect-tty` | [TTY Detectors] | `std` |
/// | `detect-env` | [Environment Variable Checkers] | `std` |
/// | [`detect-tty`, `detect-env`] | All Above, [Combo Detectors] | `std` |
///
/// For example, to enable the TTY detectors, enable the `detect-tty` feature:
///
Expand Down Expand Up @@ -314,22 +312,22 @@ macro_rules! conditions {
}

#[cfg(feature = "detect-tty")]
use is_terminal::is_terminal as is_tty;
use std::io::IsTerminal;

conditions! { feature = "detect-tty"
is_tty(&std::io::stdout()),
std::io::stdout().is_terminal(),
STDOUT_IS_TTY: stdout_is_tty,
STDOUT_IS_TTY_LIVE: stdout_is_tty_live,

is_tty(&std::io::stderr()),
std::io::stderr().is_terminal(),
STDERR_IS_TTY: stderr_is_tty,
STDERR_IS_TTY_LIVE: stderr_is_tty_live,

is_tty(&std::io::stdin()),
std::io::stdin().is_terminal(),
STDIN_IS_TTY: stdin_is_tty,
STDIN_IS_TTY_LIVE: stdin_is_tty_live,

is_tty(&std::io::stdout()) && is_tty(&std::io::stderr()),
std::io::stdout().is_terminal() && std::io::stderr().is_terminal(),
STDOUTERR_ARE_TTY: stdouterr_are_tty,
STDOUTERR_ARE_TTY_LIVE: stdouterr_are_tty_live,
}
Expand Down