Crates.io | rcolors |
lib.rs | rcolors |
version | 0.1.1 |
source | src |
created_at | 2024-09-04 13:30:45.650056 |
updated_at | 2024-09-04 13:40:16.617481 |
description | A simple terminal colorization/style tool written in Rust. |
homepage | https://github.com/StevenCyb/rcolors |
repository | https://github.com/StevenCyb/rcolors |
max_upload_size | |
id | 1363343 |
size | 145,988 |
RColor lets you use styled outputs in terms of ANSI Escape Codes in Rust.
The following colors are supported by macros: black
, red
, green
, yellow
, blue
, magenta
, cyan
and white
.
use rcolors::*;
fn main() {
// like `print` but with color suffix
print_red!("This is red print! ");
// like `println` but with color suffix
println_red!("This is red println!");
// like `format`
let x = red!("This is a value");
println!("{}", x);
}
The builder makes it easier to build complex colored text sections. Unlike the macros, the builder also offers style ANSI codes. E.g.:
fn main() {
Builder::new()
.bold().fg_yellow().text("Language: ").reset()
.fg_cyan().italic().text("Rust\n").reset()
.bold().fg_yellow().text("Username: ").reset()
.fg_cyan().italic().text("root\n").reset()
.bold().fg_yellow().text("Password: ").reset()
.fg_cyan().italic().text("********\n")
// .print();
// .println();
.as_string();
}