better_term
A rust crate designed to allow easy styling of terminal output using standard ANSI escape codes.
Usage
Style
A struct used to style output
use Style;
// prints out Hello world! underlined and bold
let style = default.underline.bold;
println!;
Color
A struct used to be simple for just changing colors
use Color;
// prints Hello, world! in green and red
println!;
Flushing Styles and Colors
It may be useful to reset all the changes you have made, and go back to the default output style. the flush_styles()
function is meant for this.
use ;
// prints the text in rainbow colors
println!;
// clear all colors and styles to reset to default
flush_styles;
println!;
Input
use ;
// gets a string from stdin, with a prompt
let input: String = read_input!;
// gets true if the user enters a value for yes, and false if the user enters no
let prompt: bool = yesno_prompt!;
// ...
Fancy
The fancy
feature is not enabled by default. It currently adds the gradient() function which will return a gradient from a start color to an end color with a given length.
More tools are planned for this feature in the future.
use gradient;
use Color;
// prints a gradient from red to green with 10 steps
let gradient = gradient;
for color in gradient