#console #colorful #colored-text #console-log #terminal #logging #warn

bin+lib colorful-console

A simple way to get colored text in the console!

3 releases (breaking)

0.3.0 Oct 22, 2024
0.2.0 Oct 20, 2024
0.1.1 Oct 20, 2024
0.1.0 Oct 20, 2024

#293 in Command-line interface


Used in ffg

MIT license

7KB
115 lines

Colorful Console

A simple crate made to add a little bit of color to your basic terminal. Can be used to color your terminal, but is best used for making logging look both clean, but also convey enough information.

Example usage

use colorful_console::*; // Imports the crate

fn main() {
  // Prints "Starting" in the standard color (Color::Reset)
  console::log("Starting", Color::Reset);
  
  // Shows how to use the `color_wrap()` function 
  console::warn(&*format!("Could {} instantiate", color_wrap("not", Color::Red)), Color::Reset);
  
  console::error("Something went wrong, restarting soon", Color::Reset);
  
  // Clears the terminal screen
  clear_terminal();
}

lib.rs:

A crate to make using colored text in the terminal easy

Example

use colorful_console::*;

fn main() {
  console::log("Starting", Color::Reset);
  console::warn(&*format!("Could {} instantiate", color_wrap("not", Color::Red)), Color::Reset);
  console::error("Something went wrong, restarting soon", Color::Reset);
  clear_terminal();
}

Dependencies

~1MB
~18K SLoC