
Vari
Vari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal. Like Rich library for Python.
Väri means "color" in Finnish.
Installing
Vari come with color anchors as default feature, The other opt-in features are: "log", "fun",
[]
= "0.1.8"
Features
Color Anchor
This is in default features.
Color anchor are a bbcode-like markup for colors and styles (eg. "[$red]", "[bg$yellow]", "[$bold]")
// [$/] is shorthand for [$reset]
let message = format;
println!;
// Custom RGB!
println!;
// Style anchor and also easy macros :O
vprintln!;
// Background color
vprintln!
// Hexadecimal
vprintln!;
Colorize
[]
= { = "0.2.0", = ["colorize"] }
Colorize string directly by calling colorize() method, like colored crate.
For example: "red".colorize("red") is the same as "[$red]red[$/]"
Note: Chaining is not yet implemented, because .colorize() adds [$/] so you can't chain styles
The argument should be the color's name (the same name as the anchor colors).
use Colorize;
Log
[]
= { = "0.1.8", = ["log"] }
Some println-ish function for logging
let log_message = vformat!;
let log_file = vformat!;
log;

No ANSI for .len()
This is in default features.
This might be used in padding calculation, because in colored string (eg. "\x1b[31mTest\x1b[0m"), the length calculated also contains the "[31m" and the "[0m" in it, making the padding incorrect. So this trait implements a ".no_ansi()" which remove all the ANSI escape sequence and then you could do ".len()" after it.
// vari::util::log()
// Calculate padding amount between the message.
// eg. left________right
let padding_amount = w - right.no_ansi.len - left.no_ansi.len;
let padding = " ".repeat;
let mut result = Stringnew;
result.push_str;
result.push_str;
result.push_str;
return result

Fun
[]
= { = "0.1.8", = ["fun"] }
License
This crate is under AGPL-3.0 license.