zolt/
lib.rs

1//! This is an opinionated CLI library for beautiful and user-friendly terminal
2//! output. It aims to give the Rust ecosystem similar tooling as
3//! [Rich](https://github.com/Textualize/rich) for Python.
4//!
5//! Note that the library is still very much a work in progress.
6//!
7//! # Available utilies
8//! - [CLI messaging](msg)
9//!
10//! # Enabling/disabling color
11//! Most of the functions in this library include color in some fashion when
12//! printing to the terminal.
13//!
14//! Color will be automatically disabled in any of these circumstances:
15//! - The `NO_COLOR` environment variable is set
16//! - The `CLICOLOR` environment variable is set to `0`
17//! - [`std::io::Stdout`] isn't a TTY (i.e. when being piped or in a noninteractive terminal)
18//!
19//! The above situations are ignored in any of these circumstances:
20//! - The `CLICOLOR` environment variable is set to anything other than `0`
21//! - The `CLICOLOR_FORCE` environment variable is set
22//!
23//! CLI coloring can also be manually set on and off through the [`show_color`] function.
24pub mod msg;
25
26pub use colored;
27
28#[doc(no_inline)]
29pub use colored::Colorize;
30
31#[doc(no_inline)]
32pub use msg::{
33    debug, debugfmt, debugln, err, errfmt, errln, info, infofmt, infoln, warn, warnfmt, warnln,
34};
35
36/// Whether coloring should be on or off.
37///
38/// If this function is never called, coloring behavior is automatically decided
39/// (see [Enabling/disabling color](crate#enablingdisabling-color)).
40#[inline(always)]
41pub fn show_color(show: bool) {
42    colored::control::set_override(show);
43}