[][src]Crate cli_table

A crate for printing tables on command line

Usage

use std::io::Result;

use cli_table::{Cell, CellFormat, Justify, Row, Table};

fn main() -> Result<()> {
    let justify_right = CellFormat::builder().justify(Justify::Right).build();
    let bold = CellFormat::builder().bold(true).build();

    let table = Table::new(vec![
        Row::new(vec![
            Cell::new(&format!("Name"), bold),
            Cell::new("Age (in years)", bold),
        ]),
        Row::new(vec![
            Cell::new("Tom", Default::default()),
            Cell::new("10", justify_right),
        ]),
        Row::new(vec![
            Cell::new("Jerry", Default::default()),
            Cell::new("15", justify_right),
        ]),
        Row::new(vec![
            Cell::new("Scooby Doo", Default::default()),
            Cell::new("25", justify_right),
        ]),
    ]);

    table.print_std()
}

Structs

Cell

A Cell in a Table

CellFormat

Struct for configuring a Cell's format

CellFormatBuilder

Builder for CellFormat

Row

A Row in a Table

Table

Struct for building a Table on command line

Enums

Align

Used to vertically align contents of a Cell

Color

The set of available colors for the terminal foreground/background.

Justify

Used to horizontally justify contents of a Cell