Skip to main content

Crate verynicetable

Crate verynicetable 

Source
Expand description

Number one table.

Very basic and lightweight table builder to print tabular data.

The struct of interest is Table, which is a builder that implements Display.

§Examples

use std::fmt::Alignment::{Left, Right};
use verynicetable::Table;

let ports = vec![
    vec!["rapportd", "449", "Quentin", "*:61165"],
    vec!["Python", "22396", "Quentin", "*:8000"],
    vec!["foo", "108", "root", "*:1337"],
    vec!["rustrover", "30928", "Quentin", "127.0.0.1:63342"],
    vec!["Transmiss", "94671", "Quentin", "*:51413"],
    vec!["Transmiss", "94671", "Quentin", "*:51413"],
];

let table = Table::new()
    .headers(&["COMMAND", "PID", "USER", "HOST:PORT"])
    .alignments(&[Left, Right, Left, Right])
    .data(&ports)
    .max_rows(5)
    .to_string();

assert_eq!(
    table,
    "\
COMMAND      PID  USER           HOST:PORT
rapportd     449  Quentin          *:61165
Python     22396  Quentin           *:8000
...          ...  ...                  ...
rustrover  30928  Quentin  127.0.0.1:63342
Transmiss  94671  Quentin          *:51413
Transmiss  94671  Quentin          *:51413
"
);

Structs§

Table
Table builder.