Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork131
A rust console and terminal abstraction
License
console-rs/console
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
console is a library for Rust that provides access to various terminalfeatures so you can build nicer looking command line interfaces. Itcomes with various tools and utilities for working with Terminals andformatting text.
Best paired with other libraries in the family:
The terminal is abstracted through theconsole::Term
type. It caneither directly provide access to the connected terminal or by bufferingup commands. A buffered terminal will however not be completely bufferedon 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!")?;thread::sleep(Duration::from_millis(2000));term.clear_line()?;
console
automatically detects when to use colors based on the tty flag, following theclicolors standard for color enabling/disabling. It alsoprovides higher level wrappers for styling text and other things that can bedisplayed with thestyle
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"));
The crate provides the functionstrip_ansi_codes
to remove ANSI codesfrom a string as well asmeasure_text_width
to calculate the width of astring as it would be displayed by the terminal. Both of those togetherare useful for more complex formatting.
By default this crate depends on theunicode-width
crate to calculatethe width of terminal characters. If you do not need this you can disabletheunicode-width
feature which will cut down on dependencies.
License: MIT
About
A rust console and terminal abstraction
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.