colorism

Crates.iocolorism
lib.rscolorism
version0.1.0
sourcesrc
created_at2022-07-04 20:59:47.460643
updated_at2022-07-04 20:59:47.460643
descriptionA library to use terminal ANSI colors
homepagehttps://github.com/z3oxs/colorism
repositoryhttps://github.com/z3oxs/colorism
max_upload_size
id619197
size6,881
(z3oxs)

documentation

README

Colorism

A library to use terminal ANSI colors

 

❗️ Install:

cargo add colorism

 

🚀 Usage:

Using the foreground method:

// Import the fore method and RESET
use colorism::{foreground::Fore, util::RESET};

// Use RESET on all string ends, if you don't, the colors will escape to your terminal and will be really ugly, but not danger.
fn main() {
    // Green regular text
    println!("{}Hello, world!{}", Fore::color(Fore::Green), RESET);

    // Green bold text
    println!("{}Hello, world!{}", Fore::color(Fore::BdGreen), RESET);
}

 

Using the background method:

use colorism::{background::Back, util::RESET};

// Use RESET on all string ends, if you don't, the colors will escape to your terminal and will be really ugly, but not danger.
fn main() {
    // Green background, white text
    println!("{}Hello, world!{}", Back::color(Back::Green), RESET);

    // Green background, white bold text
    println!("{}Hello, world!{}", Back::color(Fore::BdGreen), RESET);
}

 

Using the utils:

// Import the util and (We will use Style to styling texts) RESET
use colorism::util::{Style, RESET};

// Use RESET on all string ends, if you don't, the colors will escape to your terminal and will be really ugly, but not danger.
fn main() {
    // Simple bold text
    println!("{}I am a text{}", Style::text(Style::Bold), RESET);

    // Simple underline text
    println!("{}I am a text{}", Style::text(Style::Underline), RESET);
}
Commit count: 3

cargo fmt