verynicetable 0.2.0

Number one table.
Documentation

very nice table

license: MIT GitHub Tag crates.io GitHub Actions Workflow Status

Number one table.

Very basic and lightweight table builder to print tabular data.

Example

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

fn main() {
    let ports = vec![
        vec!["rapportd", "449", "Quentin", "*:61165"],
        vec!["Python", "22396", "Quentin", "*:8000"],
        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:PORTS"])
        .alignments(&[Left, Right, Left, Right])
        .data(&ports)
        .to_string();

    print!("{table}");
}
COMMAND      PID  USER          HOST:PORTS
rapportd     449  Quentin          *:61165
Python     22396  Quentin           *:8000
rustrover  30928  Quentin  127.0.0.1:63342
Transmiss  94671  Quentin          *:51413
Transmiss  94671  Quentin          *:51413

That's about it.

Roadmap

Not much, but will likely add some sort of "max rows" setting, and allow omitting headers which is not yet possible.

Max rows would look like this:

let table = Table::new()
    .max_rows(3)
    .headers(&["COMMAND", "PID", "USER", "HOST:PORTS"])
    .alignments(&[Left, Right, Left, Right])
    .data(&ports)
    .to_string();
COMMAND      PID  USER          HOST:PORTS
rapportd     449  Quentin          *:61165
...          ...  ...                  ...
Transmiss  94671  Quentin          *:51413
Transmiss  94671  Quentin          *:51413