anstream: simplifying terminal styling

submited by
Style Pass
2023-03-17 23:00:06

Much like with syntax highlighting with code, styling a CLI is a quick way to make the output more approachable and faster to scan. Despite this, it took me several years to add color to my CLIs because of the initial hump to get started, having to answer questions like "which styling crate should I use?".

Initially, I took the cheap way out and used env_logger for all of my output, relying on the coloring of the log levels. A problem I had is I wanted to customize the way the log levels looked but then they were no longer colored. Going back now, it appears that env_logger has a bespoke styling API but I never found it back then.

termcolor is a safe choice, being used in applications like ripgrep. The big selling point was support for older Windows versions but this came at a huge cost to ergonomics. As is usual in open source, I decided to shortchange some Windows users for my own convenience and decided against termcolor.

yansis global control didn't work as well as I had hoped and I ended up doing the bookkeeping myself using an experimental crate, concolor

Leave a Comment