ansi-colors
What is it and what is it for?
ansi-colors is a rust crate(library) that should be used to format terminal string outputs. ansi-colors offers the ansi string coloring pallet, and the string formatting pallet in order to help you color, format and beutify you output! ansi-colors works best(for now) with the ubuntu terminal coloring scheme, but it still may work on some windows and mac computers.
How to install it?
you can use cargo(the preferable and much easier and safe way):
:~$ cargo install ansi-colors
or you can clone this repository:
:~$ git clone https://github.com/l-tools/ansi-colors ansi-colors
:~$ cd ansi-colors
:~$ cargo build
Usage
Add the following to your Cargo.toml:
-colors = "0.1.0"
ansi
First use import the crate:
extern crate ansi_colors;
use *;
Then you create a new mutable coloured string using an &str primitive type
Next comes the formatting:
str1.blue;
str1.bold;
str1.underline;
Finally you print:
println!;
}
Together it looks like that:
Or this:
If you want to checkout the crate further that you should take a look in the examples folder.
Currently being developed:
- background and reseting options.
- the ability to use them in the same row(str1.blue().bold() for example).
- integrating with termi-graphics(my other crate), and creating some higher level api for the terminal graphics.
License
This crate is primarily distributed under the terms of the MIT license See LICENSE-MIT for details.