Vari (Väri) is a Rust library for formatting strings with colors and cosmetic stuff to the terminal. Like Rich library for Python.
toml
[dependencies]
vari = "0.1.7"
Color anchor are a bbcode-like markup for colors and styles (eg. "[\$red]", "[bg\$yellow]", "[\$bold]")
Anchors
Colors:
Bright colors:
Styles
Note: [bg$any] is a valid anchors, it will be translated to [$reversed][$any] (where `any` is the color/style name above)
```rust // [$/] is shorthand for [$reset] let message = vari::format("[$blue]Hello, [$green]World![$/]"); println!("{}", message);
// Custom RGB! println!("{}", vari::format("[$[114, 119, 39]]#727727![$[66, 4, 32]] Do you see it?[$/]"));
// Style anchor and also easy macros :O vprintln!("{}Bold and Italic :O{}", "[$bold][$italic]", "[$/]");
// Background color vprintln!("{}Backgroundssss{}[$/]", "[bg$magenta]", "[bg$[188, 188, 188]]World![$/]")
// Hexadecimal vprintln!("[$#ffffff]Hello, [$#000000]World![$/]"); ```
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). ```rust use vari::colorize::Colorize;
fn main() { println!("{}", "Hello, World".colorize("cyan")); println!("{}", "This is red".colorize("brightred")); println!("{}", "Bold.".colorize("bold")); } ```
rust
fn main() {
// Rainbow colors!
println!("{}", vari::fun::rainbow("Rainbow!!!"));
}
This crate is under AGPL-3.0 license.