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

#1512 in Command line utilities

Download history 42/week @ 2023-11-20 19/week @ 2023-11-27 19/week @ 2023-12-04 17/week @ 2023-12-11 43/week @ 2023-12-18 15/week @ 2023-12-25 8/week @ 2024-01-01 47/week @ 2024-01-08 47/week @ 2024-01-15 32/week @ 2024-01-22 21/week @ 2024-01-29 96/week @ 2024-02-05 64/week @ 2024-02-12 56/week @ 2024-02-19 110/week @ 2024-02-26 85/week @ 2024-03-04

319 downloads per month
Used in 5 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