Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This upgrades to 2018 edition and cuts down on dependencies.
- Loading branch information
Showing
12 changed files
with
159 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ rust: | |
- nightly | ||
|
||
script: | ||
- cargo test | ||
- make test | ||
- if [ "$TRAVIS_RUST_VERSION" = stable ]; then make lint; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
all: test | ||
.PHONY: all | ||
|
||
format: | ||
@rustup component add rustfmt 2> /dev/null | ||
@cargo fmt --all | ||
.PHONY: format | ||
|
||
format-check: | ||
@rustup component add rustfmt 2> /dev/null | ||
@cargo fmt --all -- --check | ||
.PHONY: format-check | ||
|
||
lint: | ||
@rustup component add clippy 2> /dev/null | ||
@cargo clippy | ||
.PHONY: lint | ||
|
||
update-readme: | ||
@cargo readme > README.md | ||
.PHONY: update-readme | ||
|
||
test: | ||
@cargo test | ||
@cargo test --no-default-features | ||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,70 @@ | ||
# console | ||
|
||
[![Build Status](https://travis-ci.org/mitsuhiko/console.svg?branch=master)](https://travis-ci.org/mitsuhiko/console) | ||
[![Latest Version](https://img.shields.io/crates/v/console.svg)](https://crates.io/crates/console) | ||
[![docs](https://docs.rs/console/badge.svg)](https://docs.rs/console) | ||
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. | ||
|
||
A console and terminal abstraction for Rust. | ||
Best paired with other libraries in the family: | ||
|
||
Adds colors and other useful things to your terminal life. | ||
* [dialoguer](https://docs.rs/dialoguer) | ||
* [indicatif](https://docs.rs/indicatif) | ||
|
||
## 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: | ||
|
||
```rust | ||
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()?; | ||
``` | ||
|
||
## 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: | ||
|
||
```rust | ||
use console::style; | ||
|
||
println!("This is {} neat", style("quite").cyan()); | ||
``` | ||
|
||
You can also store styles and apply them to text later: | ||
|
||
```rust | ||
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 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` feature which will cut down on dependencies. | ||
|
||
License: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
extern crate console; | ||
|
||
use console::style; | ||
|
||
fn main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
extern crate console; | ||
|
||
use std::io::{self, Write}; | ||
use std::thread; | ||
use std::time::Duration; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters