Terminal access, colours and styling for Rust command-line apps
open sourceMITfree
console is a Rust library from the console-rs family for building nicer command-line interfaces: a Term type for reading from and writing to the terminal (clearing lines, moving the cursor, buffered output), text colours and styles that turn themselves on or off by whether output is a terminal, following the clicolors convention, and helpers to strip ANSI codes and measure how wide text displays. It pairs with indicatif and dialoguer from the same family.
Problems it solves
- colour and style text in my Rust CLI only when output goes to a terminal
- clear lines and move the cursor in a Rust terminal app
- measure how wide a string with ANSI colour codes displays in the terminal
Features
- Term type for terminal access, directly or buffered
- colours and styles with style() and reusable Style values
- colour detection from the tty, following the clicolors convention
- strip_ansi_codes and measure_text_width for formatting
- optional unicode-width dependency
Alternatives
The same job
These do what console does.