teamy-figue 2.0.1

Type-safe CLI arguments, config files, and environment variables powered by Facet reflection
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::env::var_os;
use supports_color::Stream;

/// Determine if the output should be colored.
///
/// This respects the [`NO_COLOR`](https://no-color.org) and [`FORCE_COLOR`] environment variables.
pub fn should_use_color() -> bool {
    // Don't use color when creating snapshots for `insta`. Color isn't disabled for testing in general
    // to allow coloring to be tested, plus there is no clear way to detect when this code is being
    // executed as part of an integration test.
    var_os("INSTA_UPDATE").is_none()
        && var_os("INSTA_WORKSPACE").is_none()
        && var_os("INSTA_SNAPSHOT_UPDATE").is_none()
        && supports_color::on(Stream::Stdout).is_some()
}