#table #cli #terminal #ascii #pretty

text-tables

A terminal/text table prettifier with no dependencies

7 releases

Uses old Rust 2015

0.3.1 Mar 3, 2019
0.3.0 Mar 3, 2019
0.2.3 Feb 27, 2018
0.1.0 Feb 27, 2018

#369 in Text processing

Download history 24/week @ 2021-10-03 31/week @ 2021-10-10 43/week @ 2021-10-17 30/week @ 2021-10-24 83/week @ 2021-10-31 73/week @ 2021-11-07 118/week @ 2021-11-14 59/week @ 2021-11-21 133/week @ 2021-11-28 220/week @ 2021-12-05 102/week @ 2021-12-12 36/week @ 2021-12-19 22/week @ 2021-12-26 103/week @ 2022-01-02 103/week @ 2022-01-09 157/week @ 2022-01-16

385 downloads per month

MIT/Apache

7KB
113 lines

Text-tables

This library provides very simple table printing using text characters. It has no dependencies besides std. I'm interested in making it no_std if this is possible, contributions welcome!

Licensed under MIT or Apache-2.0 at your discretion. Message me if this isn't sufficient.

Example

extern crate text_tables;

use std::str;
use std::io;

fn main() {
    // can be vec or slices
    let data = [["A", "2x2"], ["pretty", "table"]];
    // we can either render to an array...
    let mut out = Vec::new();
    text_tables::render(&mut out, data).unwrap();
    println!("{}", str::from_utf8(&out).unwrap());
    // ...or we can use `Write` streams directly
    text_tables::render(&mut io::stdout(), data).unwrap();
}

outputs

+--------+-------+
| A      | 2x2   |
+--------+-------+
| pretty | table |
+--------+-------+

lib.rs:

A small library for pretty-printing tables in monospace text.

Example

let data = [["Some", "printable"], ["data", "fields"]];
let mut out = Vec::new();
text_tables::render(&mut out, data).unwrap();
println!("{}", ::std::str::from_utf8(&out).unwrap());

No runtime deps