Skip to main content

basic/
basic.rs

1//! # Basic example
2//!
3//! Coloring is active in the terminal, but is inactive when redirected to another process.
4//!
5//! Running this example in terminal will display colored text:
6//!
7//! ```shell
8//! cargo run --example basic
9//! ```
10//!
11//! Redirecting the output to another process will cancel coloring:
12//!
13//! ```shell
14//! cargo run --example basic | cat
15//! ```
16
17use antex::{StyledText, Text};
18
19fn main() {
20  println!(
21    "{}",
22    Text::auto()
23      .s("Foreground colors:\n")
24      .black()
25      .s(" 0 ")
26      .red()
27      .s(" 1 ")
28      .green()
29      .s(" 2 ")
30      .yellow()
31      .s(" 3 ")
32      .blue()
33      .s(" 4 ")
34      .magenta()
35      .s(" 5 ")
36      .cyan()
37      .s(" 6 ")
38      .white()
39      .s(" 7 ")
40      .reset()
41  );
42}