5 releases (1 stable)

1.0.0 Dec 31, 2022
0.9.0 Dec 30, 2022
0.8.7 Dec 30, 2022
0.8.6 Dec 30, 2022
0.8.5 Dec 30, 2022

#2724 in Command line utilities

Download history 66/week @ 2024-07-21 87/week @ 2024-07-28 66/week @ 2024-08-04 71/week @ 2024-08-11 74/week @ 2024-08-18 66/week @ 2024-08-25 52/week @ 2024-09-01 87/week @ 2024-09-08 50/week @ 2024-09-15 64/week @ 2024-09-22 59/week @ 2024-09-29 10/week @ 2024-10-06 54/week @ 2024-10-13 43/week @ 2024-10-20 58/week @ 2024-10-27 91/week @ 2024-11-03

247 downloads per month
Used in 11 crates

MIT license

9KB
119 lines

Colorized

Colorized is a simple rust library that allows for you to display color to the console

Getting Started

Just add the line on crates.io to your Cargo.toml to install it

Usage

To use Colorized all you have to do is

use colorized::*;

fn main() {
  println!("{}", "This is so cool".color(Colors::BrightGreenFg));
  let this: String = colorize_this("wowzers", Colors::BrightBlackBg);
  colorize_print("Wow this is great", Colors::BrightCyanFg);
  colorize_println("Wow this is great", Colors::BrightCyanFg);
}

Documentation

Colorized uses ASCI Codes and thats how it remains very simple. In the source code you may be able to tell that it is my first time making and uploading a libary but I hope this libary could be useful.

Colors Enum

This enum makes it easy to access all of the colors and color values.

Examples

use colorized::*;

fn main() {
  println!("This is with color:  {} woah {}", Colors::BlueFg.value(), Colors::Reset.value());
  println!("Same thing but easier: {}", "Oh my".color(Colors::BrightCyanBg));
  let coloredString = colorize_this("This is color", Colors::YellowFg);
}

Implementation

The implementation that allows the Colors Enum to a &str value

Examples

use colorized::Colors;

fn main() {
  assert_eq!(Colors::BlueFg.value(), "\x1b[34m")
}

Colors Traits

This allows Strings and &str to have color with .color(COLOR_ENUM)

Examples

use colorized::*;

fn main() {
    println!("{}", "Wow".color(Colors::CyanFg));
    let john: String = String::from(":)");
    println!("{}",  john.color(Colors::BrightMagentaBg));
}

Colorize Print

This is a funcition that prints a full colored sentence without a new line charactor

Examples

use colorized::*;

fn main() {
  colorize_print("Wow this is great", Colors::BrightCyanFg);
}

Colorize PrintLn

This is a funcition that prints a full colored sentence with a new line charactor

Examples

use colorized::*;

fn main() {
  colorize_println("Wow this is great", Colors::BrightCyanFg);
}

Colorize this

This function adds color to anything that isn't implemented

Examples

use colorized::*;

fn main() {
  let this: String = colorize_this("wowzers", Colors::BrightBlackBg);
}

Format of color

Colors::{COLORNAME}_

All Posible Colors

  1. black
  2. red
  3. green
  4. yellow
  5. blue
  6. magenta
  7. cyan
  8. white
  9. bright_black
  10. bright_red
  11. bright_green
  12. bright_yellow
  13. bright_blue
  14. bright_magenta
  15. bright_cyan
  16. bright_white

License

MIT

No runtime deps