#pretty #terminal #ascii #table #cli

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

#2163 in Text processing

Download history 169/week @ 2024-12-14 47/week @ 2024-12-21 47/week @ 2024-12-28 153/week @ 2025-01-04 193/week @ 2025-01-11 143/week @ 2025-01-18 114/week @ 2025-01-25 102/week @ 2025-02-01 148/week @ 2025-02-08 166/week @ 2025-02-15 232/week @ 2025-02-22 269/week @ 2025-03-01 202/week @ 2025-03-08 209/week @ 2025-03-15 279/week @ 2025-03-22 143/week @ 2025-03-29

849 downloads per month
Used in 2 crates

MIT/Apache

8KB
113 lines

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());

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 |
+--------+-------+

No runtime deps