lil-tabby

Crates.iolil-tabby
lib.rslil-tabby
version0.1.2
created_at2025-08-23 06:47:53.902877+00
updated_at2025-08-23 13:13:48.837291+00
descriptionA macro-based library for creating visually appealing tables with automatic column spanning
homepagehttps://github.com/ivs-ug/lil-tabby
repositoryhttps://github.com/ivs-ug/lil-tabby
max_upload_size
id1807272
size27,133
Ivan (ivs-ug)

documentation

README

lil-tabby 🐱‍💻

Crates.io Documentation License Build Status

A lightweight Rust macro for building beautiful terminal tables — with automatic column spanning, header handling, and colorful styling — all powered by tabled.

Perfect for CLI tools, inspectors, and any app that needs clean, readable terminal output.

Features

  • Auto Column Spanning — Short rows automatically span to fill width.
  • First Row as Header — Or data. No extra config needed.
  • Rich Styling — Customize style, colors, borders, and bold headers.
  • Two Syntaxes — Inline literals or from Vec<Vec<String>>.
  • Extensible — Re-exports tabled for advanced tweaks.
  • Zero Boilerplate — Just tabby![] and go.

Installation

Add to your Cargo.toml:

[dependencies]
lil-tabby = "0.1.2"

Usage

Basic Table (Inline)

use lil_tabby::tabby;

let table = tabby![
    { style: ascii }
    ["Name", "Type"],
    ["Some", "Field"],
    ["Above", "Will", "Span"]
];
println!("{}", table);

Output:

+-------+-------------+
| Name  | Type        |
+-------+-------------+
| Some  | Field       |
+-------+------+------+
| Above | Will | Span |
+-------+------+------+

Styled Table with Options

use lil_tabby::tabby;

let table = tabby![
    { style: modern_rounded, header: green, labels: yellow, color: blue, border: red, bold: true }
    ["Package", "Version"],
    ["tokio", "1.0"],
    ["serde", "1.0", "active"]
];
println!("{}", table);

From Vec<Vec<String>>

use lil_tabby::tabby;

let data: Vec<Vec<String>> = vec![
    vec!["Header 1".to_string(), "Header 2".to_string(), "Header 3".to_string()],
    vec!["Row 1".to_string()],
    vec!["Row 2 Col 1".to_string(), "Row 2 Col 2".to_string()]
];

println!("{}", tabby!(data));

Post-Creation Modification

tabled re-export:

use lil_tabby::{tabby, tabled};

let mut table = tabby![
    { style: ascii, border: bright_green }
    ["a", "b", "c"],
    ["d", "e"],
    ["f"]
];

// Align all columns to the right
table.with(tabled::settings::Alignment::right());

println!("{}", table);

Output:

+---+---+---+
| a | b | c |
+---+---+---+
| d |     e |
+---+-------+
|         f |
+-----------+

Styling Options

The optional { ... } block supports:

Option Values Default Maps To
style modern_rounded, ascii, ... modern_rounded Style::...
header red, green, bright_black, ... white FG_COLOR
labels same as above white First column
color same as above white Content cells
border same as above bright_black Border lines
bold true / false false Header bolding

Color names match tabled::settings::Color::FG_* (lower-case in macro).

Example:

tabby![
    { style: ascii, header: bright_yellow, color: blue, border: red, bold: true }
    ["some", "data"]
]

Limitations

  • Max 20 columns (due to const generic limits in tabled).
    → Anyway, won't fit the screen. Like 640kb, should be enough.
  • Colors must be mapped to valid tabled color names (e.g., bright_green, not lime).

Why This Exists

tabled is powerful, but awkward for quick CLI tables:

  • No easy header handling
  • Manual spanning
  • Repetitive styling

License

MIT — Do whatever you want. Credit appreciated, not required.

Commit count: 10

cargo fmt