ansi-style 1.2.1

ANSI escape codes for styling strings in the terminal
Documentation
  • Coverage
  • 99.07%
    107 out of 108 items documented1 out of 69 items with examples
  • Size
  • Source code size: 28.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.95 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • martial-plains/ansi-style
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • martial-plains

ansi-style

CI rust-clippy analyze

ANSI escape codes for styling strings in the terminal

Adding ansi-style as a dependency

[dependencies]
ansi-style = "1.2.1"

Usage

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")
    )
}