28 releases

0.12.0 Aug 10, 2020
0.11.3 May 18, 2020
0.11.2 Apr 28, 2020
0.10.0 Mar 8, 2020
0.5.0 Jun 28, 2017

#5 in Command-line interface

Download history 38058/week @ 2020-06-01 38394/week @ 2020-06-08 41206/week @ 2020-06-15 39681/week @ 2020-06-22 43973/week @ 2020-06-29 39653/week @ 2020-07-06 42036/week @ 2020-07-13 39476/week @ 2020-07-20 42566/week @ 2020-07-27 40710/week @ 2020-08-03 43656/week @ 2020-08-10 44356/week @ 2020-08-17 46660/week @ 2020-08-24 46598/week @ 2020-08-31 48015/week @ 2020-09-07 46356/week @ 2020-09-14

169,922 downloads per month
Used in 555 crates (166 directly)

MIT license



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:

Terminal Access

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.

Example usage:

use std::thread;
use std::time::Duration;

use console::Term;

let term = Term::stdout();
term.write_line("Hello World!")?;

Colors and Styles

console uses clicolors-control to control colors. It also provides higher level wrappers for styling text and other things that can be displayed with the style function and utility types.

Example usage:

use console::style;

println!("This is {} neat", style("quite").cyan());

You can also store styles and apply them to text later:

use console::Style;

let cyan = Style::new().cyan();
println!("This is {} neat", cyan.apply_to("quite"));

Working with ANSI Codes

The crate provids 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 the unicode-width feature which will cut down on dependencies.

License: MIT