I've been using color-print for most of my Rust projects because I like the HTML-ish cprintln!("<red>error:</red> oops") syntax for adding color to terminal output. Unfortunately, color-print doesn't detect non-interactive environments where color codes don't make sense, for example when piping the output to a file or another program.
So I forked color-print to clml (short for command-line markup language) to add support for anstream. It takes advantage of anstream's terminal capability detection to be smarter about when to emit the color terminal codes.
Bonus: since I was making changes, I also added support for indoc-esque multiline strings and terminal hyperlinks to clml.
fn main() {
let name = "world";
let count = 3;
cprintlndoc!("
<green,bold>Hello, {name}!</>
<dim>Indented one level further.</>
You have <yellow>{count}</> new messages.
See <link(https://example.com)>the docs</>.
"
);
}
Check it out!
As a side note, this was the first crate I've ever published, and it was pretty painless! I'm happy with how the library turned out so it's nice to be able to share it, to give back a bit. Happy Thursday!