How to add colored output to CLI

Cli
Enable colored CLI output in Rust by setting RUSTC_COLOR=always or using the --color=always flag with cargo and rustc commands.

Enable colored output in Rust CLI tools by setting the RUSTC_COLOR environment variable or using the --color flag.

export RUSTC_COLOR=always
rustc --explain E0001

For cargo commands, use the --color flag directly:

cargo build --color=always

The rustc compiler uses the ColorConfig enum (found in rustc_errors) to determine output styling, supporting Auto, Always, and Never modes.