1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! # no_color
//!
//! [](https://crates.io/crates/no_color)
//! [](https://crates.io/crates/no_color)
//! [](https://github.com/sitkevij/no_color)
//! [](https://github.com/sitkevij/no_color/actions/workflows/ci.yml?branch=main)
//! [](https://docs.rs/no_color/0.2.0/no_color/)
//! [](https://github.com/sitkevij/no_color/blob/main/LICENSE)
//!
//! **no_color** is a zero dependency rust library for detecting if the NO_COLOR environment
//! variable is set.
//!
//! Note only the existence of the NO_COLOR environment variable is required to be valid, whether
//! the environment variable has value or not.
//!
//! ## Usage
//!
//! no_color is a library crate which works with [Cargo](http://crates.io).
//!
//! ### Add to Cargo.toml
//!
//! To use, add the following to your `Cargo.toml` dependencies section:
//!
//! ```toml
//! [dependencies]
//! no_color = "0.2"
//! ```
//!
//! or use cargo add:
//!
//! ```sh
//! $ cargo add no_color
//! ```
use env;
/// const NO_COLOR str
const ENV_VAR_NO_COLOR: &str = "NO_COLOR";
/// Function returns `true` if NO_COLOR environment variable exists, `false` if
/// not.
///
/// note: std::env::var_os function may panic if key is empty, contains an
/// ASCII equals sign '=' or the NUL character '\0', or when the value contains
/// the NUL character. Read more <https://doc.rust-lang.org/std/env/fn.var_os.html>
/// <https://medium.com/@ericdreichert/test-setup-and-teardown-in-rust-without-a-framework-ba32d97aa5ab>
/// these tests set NO_COLOR environment variable