pub mod windows;
#[inline]
pub fn clicolor() -> Option<bool> {
let value = std::env::var_os("CLICOLOR")?;
Some(value != "0")
}
#[inline]
pub fn clicolor_force() -> bool {
let value = std::env::var_os("CLICOLOR_FORCE");
value
.as_deref()
.unwrap_or_else(|| std::ffi::OsStr::new("0"))
!= "0"
}
#[inline]
pub fn no_color() -> bool {
let value = std::env::var_os("NO_COLOR");
value.as_deref().unwrap_or_else(|| std::ffi::OsStr::new("")) != ""
}
#[inline]
#[cfg(not(windows))]
pub fn term_supports_color() -> bool {
match std::env::var_os("TERM") {
None => return false,
Some(k) => {
if k == "dumb" {
return false;
}
}
}
true
}
#[inline]
#[cfg(windows)]
pub fn term_supports_color() -> bool {
if let Some(k) = std::env::var_os("TERM") {
if k == "dumb" {
return false;
}
}
true
}
#[inline]
#[cfg(not(windows))]
pub fn term_supports_ansi_color() -> bool {
term_supports_color()
}
#[inline]
#[cfg(windows)]
pub fn term_supports_ansi_color() -> bool {
match std::env::var_os("TERM") {
None => return false,
Some(k) => {
if k == "dumb" || k == "cygwin" {
return false;
}
}
}
true
}
#[inline]
pub fn truecolor() -> bool {
let value = std::env::var_os("COLORTERM");
let value = value.as_deref().unwrap_or_default();
value == "truecolor" || value == "24bit"
}
#[inline]
pub fn is_ci() -> bool {
std::env::var_os("CI").is_some()
}