rcolors

Crates.iorcolors
lib.rsrcolors
version0.1.1
sourcesrc
created_at2024-09-04 13:30:45.650056
updated_at2024-09-04 13:40:16.617481
descriptionA simple terminal colorization/style tool written in Rust.
homepagehttps://github.com/StevenCyb/rcolors
repositoryhttps://github.com/StevenCyb/rcolors
max_upload_size
id1363343
size145,988
Steven Cybinski (StevenCyb)

documentation

README

RColors

Crates.io CC0 licensed Tests Clippy Rustfmt Release

RColor lets you use styled outputs in terms of ANSI Escape Codes in Rust.

Usage

Using Macros

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);
}

Using Builder

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();
}
Commit count: 0

cargo fmt