Crates.io | ansi-style |
lib.rs | ansi-style |
version | 1.2.1 |
source | src |
created_at | 2022-10-18 20:21:22.989927 |
updated_at | 2024-05-24 19:48:18.454563 |
description | ANSI escape codes for styling strings in the terminal |
homepage | |
repository | https://github.com/martial-plains/ansi-style |
max_upload_size | |
id | 691159 |
size | 29,453 |
ANSI escape codes for styling strings in the terminal
[dependencies]
ansi-style = "1.2.1"
use ansi_style::{Color, Style};
fn main() {
// You can either color the text directly with the Color enumeration
println!(
"{}Cyan colored \"Hello World!\"{}",
Color::Cyan.open(),
Color::Cyan.close()
);
// or you can use the builder function from within the Style stuct
// to create a style that can be used for more than one instance of
// a string and you wouldn't need to have an open and close function
// prepended and appended to every text you type like the above example
let style = Style::builder().red().strikethrough().build();
println!(
"{}",
style.stylize("Hello World in red with strikethrough")
)
}