| 1 | <div align="left"> |
| 2 | <img src="https://raw.githubusercontent.com/SergioBenitez/yansi/master/.github/yansi-logo.png" |
| 3 | align="center" alt="yansi logo" width="64" height="64"> |
| 4 | <span> <b>Yansi</b></span> |
| 5 | <p>A dead simple ANSI terminal color painting library.</p> |
| 6 | |
| 7 | [](https://github.com/SergioBenitez/yansi/actions) |
| 8 | [](https://crates.io/crates/yansi) |
| 9 | [](https://docs.rs/yansi) |
| 10 | </div> |
| 11 | |
| 12 | ## Usage |
| 13 | |
| 14 | In your `Cargo.toml`: |
| 15 | |
| 16 | ```toml |
| 17 | [dependencies] |
| 18 | yansi = "1.0" |
| 19 | ``` |
| 20 | |
| 21 | In your source code: |
| 22 | |
| 23 | ```rust |
| 24 | use yansi::Paint; |
| 25 | |
| 26 | println!("Testing, {}, {}, {}!", |
| 27 | "Ready".bold(), |
| 28 | "Set".black().on_yellow().invert().italic(), |
| 29 | "STOP".white().on_red().bright().underline().bold()); |
| 30 | ``` |
| 31 | |
| 32 |  |
| 33 | |
| 34 | [See the rustdocs](https://docs.rs/yansi) for complete usage details. |
| 35 | |
| 36 | ## Features |
| 37 | |
| 38 | Why *y*et another *ANSI* terminal coloring library? Here are some reasons: |
| 39 | |
| 40 | * This library makes simple things _simple_: `use` [`Paint`] and go! |
| 41 | * Zero dependencies by default. It really is simple. |
| 42 | * Zero allocations except as needed by opt-in [wrapping]. |
| 43 | * [Automatic Windows support] for the vast majority (95%+) of Windows users. |
| 44 | * [Featureful `no_std`], no-`alloc`, support with `default-features = false`. |
| 45 | * [`Style` constructors are `const`]: store styles statically, even with |
| 46 | dynamic conditions! |
| 47 | * _Any_ type implementing a formatting trait can be styled, not just strings. |
| 48 | * Styling can be [enabled] and [disabled] globally and [dynamically], on the |
| 49 | fly. |
| 50 | * A `Style` can be predicated on arbitrary [conditions]. |
| 51 | * Formatting specifiers like `{:x}` and `{:08b}` are supported and preserved! |
| 52 | * [Built-in (optional) conditions] for [TTY detection] and [common environment |
| 53 | variables]. |
| 54 | * Arbitrary items can be [_masked_] for selective disabling. |
| 55 | * Styling can [_wrap_] to preserve styling across resets. |
| 56 | * Styling can [_linger_] beyond a single value. |
| 57 | * Experimental support for [hyperlinking] is included. |
| 58 | * The name `yansi` is pretty cool 😎. |
| 59 | |
| 60 | [`Paint`]: https://docs.rs/yansi/1.0.0/yansi/trait.Paint.html |
| 61 | [`ansi_term`]: https://crates.io/crates/ansi_term |
| 62 | [`colored`]: https://crates.io/crates/colored |
| 63 | [`term_painter`]: https://crates.io/crates/term-painter |
| 64 | [_masked_]: https://docs.rs/yansi/1.0.0/yansi/#masking |
| 65 | [wrapping]: https://docs.rs/yansi/1.0.0/yansi/#wrapping |
| 66 | [_wrap_]: https://docs.rs/yansi/1.0.0/yansi/#wrapping |
| 67 | [_linger_]: https://docs.rs/yansi/1.0.0/yansi/#lingering |
| 68 | [conditions]: https://docs.rs/yansi/1.0.0/yansi/#per-style |
| 69 | [enabled]: https://docs.rs/yansi/1.0.0/yansi/fn.enable.html |
| 70 | [disabled]: https://docs.rs/yansi/1.0.0/yansi/fn.disable.html |
| 71 | [dynamically]: https://docs.rs/yansi/1.0.0/yansi/fn.whenever.html |
| 72 | [enabled conditionally]: https://docs.rs/yansi/1.0.0/yansi/struct.Condition.html |
| 73 | [TTY detection]: https://docs.rs/yansi/1.0.0/yansi/struct.Condition.html#impl-Condition-1 |
| 74 | [common environment variables]: https://docs.rs/yansi/1.0.0/yansi/struct.Condition.html#impl-Condition-2 |
| 75 | [Automatic Windows support]: https://docs.rs/yansi/1.0.0/yansi/#windows |
| 76 | [Built-in (optional) conditions]: https://docs.rs/yansi/1.0.0/yansi/struct.Condition.html#built-in-conditions |
| 77 | [hyperlinking]: https://docs.rs/yansi/1.0.0/yansi/hyperlink/index.html |
| 78 | [`Style` constructors are `const`]: https://docs.rs/yansi/1.0.0/yansi/#uniform-const-builders |
| 79 | [Featureful `no_std`]: https://docs.rs/yansi/1.0.0/yansi/#crate-features |
| 80 | |
| 81 | ## License |
| 82 | |
| 83 | `yansi` is licensed under either of the following, at your option: |
| 84 | |
| 85 | * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 86 | * MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |