The simplest way to add colours in your terminal from Rust
open sourceMPL-2.0free
colored is a Rust crate that adds terminal colours and styles to strings through methods on a Colorize trait: "text".red().on_blue().bold(). It covers the eight standard colours and their bright versions, true colour from RGB values, tuples or hex strings, colours named by string, and styles such as bold and italic, and it works with format! padding and truncation. It respects the CLICOLOR, CLICOLOR_FORCE and NO_COLOR conventions, and works on Linux, macOS and Windows (PowerShell).
Problems it solves
- print coloured output in my Rust command-line tool
- highlight errors in red and successes in green in terminal output from Rust
- turn off colours when NO_COLOR is set without handling it myself
Features
- Colour and style strings with chained methods like .red().on_blue().bold()
- True colour from RGB values, tuples or hex strings
- Bright colours, bold, italic and other styles
- Respects CLICOLOR, CLICOLOR_FORCE and NO_COLOR
- Works with format! padding and truncation
Alternatives
The same job
These do what colored does.
