#table #terminal #cli

tableau

A library for creating pretty tables in the terminal

1 unstable release

0.1.0 Jan 28, 2025

#336 in Command-line interface

Download history 102/week @ 2025-01-28 18/week @ 2025-02-04

120 downloads per month

MIT/Apache

37KB
521 lines

Tableau

A library for building pretty tables in the terminal

About

This is a library for building pretty tables in the terminal.

This library is heavily inspired from the term-table library.

My goals with this library are:

  • to serve as a common and stable terminal table library in some of my projects, like persist or rebench-tabler.
  • to experiment and personally learn more about layout algorithms.
  • to potentially extend it with features that I find useful, or that I think would be interesting to implement.

Features

All features marked as not yet implemented are ideas of things that could be done, and not necessarily an indication of it currently being worked on.

These are also non-exhaustive, so if there is a feature that you'd like to see done, feel free to open an issue to show your interest in it, regardless of whether it is mentionned in this list or not.

If you wish to contribute to this project, feel free to use this list to see if there is something you would be interested to either work on, or simply sharing some of your knowledge on how it could be achieved.

  • Multi-line cell contents
  • Handling of ANSI colors and attributes
  • Per-cell text alignment
  • Cells spanning multiple columns
  • Cells spanning multiple rows
  • Per-column maximum width
  • Toggleable row separators

Examples

Here is an example output from the cities example:

╭─────────────────────────────────────────────────────╮
│               CITIES AROUND THE WORLD               │
├─────────────┬────────────────┬───────────┬──────────┤
│    CITY     │    COUNTRY     │ LONGITUDE │ LATITUDE │
├─────────────┼────────────────┼───────────┼──────────┤
│ Tokyo       │     Japan      │  139.6917 │  35.6895 │
│ Jakarta     │   Indonesia    │  106.8650 │  -6.1751 │
│ Delhi       │     India      │   77.1025 │  28.7041 │
│ Seoul       │  South Korea   │  126.9780 │  37.5665 │
│ Paris       │     France     │    2.3522 │  48.8566 │
│ London      │ United Kingdom │   -0.1276 │  51.5072 │
│ Beijing     │     China      │  116.4074 │  39.9042 │
│ New York    │ United States  │  -74.0060 │  40.7128 │
│ Sao Paulo   │     Brazil     │  -46.6333 │ -23.5505 │
│ Mexico City │     Mexico     │  -99.1332 │  19.4326 │
│ Mumbai      │     India      │   72.8777 │  19.0760 │
│ Los Angeles │ United States  │ -118.2437 │  34.0522 │
│ Istanbul    │     Turkey     │   28.9784 │  41.0082 │
╰─────────────┴────────────────┴───────────┴──────────╯

You can see more examples of how to use this library by looking at the different examples available.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~4.5MB
~76K SLoC