๐ term_ansi
Colorize your terminal output with ease! ๐จโจ
term_ansi is a super-light weight Rust crate that provides a simple and intuitive way to add colors and formatting to your terminal output using ANSI escape codes. With support for various predefined colors and custom RGB values, you can make your CLI applications more visually appealing and user-friendly.
โ ๏ธ Important Version Notice
Versions before v0.2.2 are unstable.
v0.2.2 and above are fully tested and stable. We strongly recommend using this version or later for production use.
๐ Table of Contents
โจ Features
- ๐จ Easy-to-use macros for applying colors
- ๐ Support for 8 predefined colors
- ๐ข Custom RGB color support
- ๐ช Nested color application
- ๐งต Thread-safe color context management
๐ฆ Installation
Add term_ansi to your Cargo.toml:
[]
= "0.2.2" # Make sure to use version 0.2.2 or later
๐ Usage
First, import the crate in your Rust file:
use *;
Basic Colors
Apply colors to your text using the provided macros:
println!;
println!;
println!;
Nested Colors
You can nest color macros for more complex formatting:
println!;
Custom RGB Colors
Use the colour! macro to apply custom RGB colors:
println!;
๐ Available Macros
red!: Apply red colorgreen!: Apply green colorblue!: Apply blue colorwhite!: Apply white colorblack!: Apply black coloryellow!: Apply yellow colormagenta!: Apply magenta colorcyan!: Apply cyan colorcolour!: Apply a custom RGB color
๐ก Examples
Simple Error Message
println!;
Colorful Status Message
println!;
Nested Color Formatting
println!;
Custom Color Gradient
for i in 0..=255
println!;
๐ค Contributing
Contributions are welcome! Do discuss any improvements in the Issues first : ) Please make sure to update tests as appropriate and adhere to the existing coding style.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding! Hope it helps ๐ฆ