console is a library for Rust that provides access to various terminal features so you can build nicer looking command line interfaces. It comes with various tools and utilities for working with Terminals and formatting text.
Best paired with other libraries in the family:
The terminal is abstracted through the
console::Term type. It can
either directly provide access to the connected terminal or by buffering
up commands. A buffered terminal will however not be completely buffered
on windows where cursor movements are currently directly passed through.
let term = stdout;
Colors and Styles
console automaticaly detects when to use colors based on the tty flag. It also
provides higher level wrappers for styling text and other things that can be
displayed with the
style function and utility types.
You can also store styles and apply them to text later:
let cyan = new.cyan;
Working with ANSI Codes
The crate provides the function
strip_ansi_codes to remove ANSI codes
from a string as well as
measure_text_width to calculate the width of a
string as it would be displayed by the terminal. Both of those together
are useful for more complex formatting.
Unicode Width Support
By default this crate depends on the
unicode-width crate to calculate
the width of terminal characters. If you do not need this you can disable
unicode-width feature which will cut down on dependencies.