• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/workflows/H03-May-2022-130129

examples/H03-May-2022-9881

src/H03-May-2022-2,7592,150

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D15-Mar-202174 65

.gitignoreH A D22-Apr-202018 32

CHANGELOG.mdH A D15-Mar-2021751 3721

Cargo.lockH A D15-Mar-20212.6 KiB9684

Cargo.tomlH A D15-Mar-20211.6 KiB5849

Cargo.toml.orig-cargoH A D15-Mar-2021995 3026

LICENSEH A D22-Apr-20201.1 KiB2317

README.mdH A D22-Apr-20201.9 KiB7148

README.md

1# console
2
3console is a library for Rust that provides access to various terminal
4features so you can build nicer looking command line interfaces.  It
5comes with various tools and utilities for working with Terminals and
6formatting text.
7
8Best paired with other libraries in the family:
9
10* [dialoguer](https://docs.rs/dialoguer)
11* [indicatif](https://docs.rs/indicatif)
12
13## Terminal Access
14
15The terminal is abstracted through the `console::Term` type.  It can
16either directly provide access to the connected terminal or by buffering
17up commands.  A buffered terminal will however not be completely buffered
18on windows where cursor movements are currently directly passed through.
19
20Example usage:
21
22```rust
23use std::thread;
24use std::time::Duration;
25
26use console::Term;
27
28let term = Term::stdout();
29term.write_line("Hello World!")?;
30thread::sleep(Duration::from_millis(2000));
31term.clear_line()?;
32```
33
34## Colors and Styles
35
36`console` uses `clicolors-control` to control colors.  It also
37provides higher level wrappers for styling text and other things
38that can be displayed with the `style` function and utility types.
39
40Example usage:
41
42```rust
43use console::style;
44
45println!("This is {} neat", style("quite").cyan());
46```
47
48You can also store styles and apply them to text later:
49
50```rust
51use console::Style;
52
53let cyan = Style::new().cyan();
54println!("This is {} neat", cyan.apply_to("quite"));
55```
56
57## Working with ANSI Codes
58
59The crate provids the function `strip_ansi_codes` to remove ANSI codes
60from a string as well as `measure_text_width` to calculate the width of a
61string as it would be displayed by the terminal.  Both of those together
62are useful for more complex formatting.
63
64## Unicode Width Support
65
66By default this crate depends on the `unicode-width` crate to calculate
67the width of terminal characters.  If you do not need this you can disable
68the `unicode-width` feature which will cut down on dependencies.
69
70License: MIT
71