ascii-table-rs
ascii-table-rs is a lightweight, flexible Rust library for rendering beautiful ASCII tables in the terminal.
It supports automatic column sizing, customizable float precision, summary rows, and Unicode box-drawing characters for a polished CLI/terminals experience.
Features
- Easy-to-use API for defining headers, rows, and summaries
- Auto-resizing columns based on content width
- Supports
String,i64, andf64cell types - Configurable decimal precision for floats (with truncation, not rounding)
- Unicode box-drawing borders for clean layout
- Unit-tested and ready for production use
Demo example
Run demo example program with:
)
Quick Start
Add to your Cargo.toml
[]
= "1.0.0"
Create and render a table
use ;
After running below program, you can see ASCII table like this:
Public API overview for this library
AsciiTable::new(title: &str)- Creates a new table with a title.set_headers(Vec<&str>)- Defines column headers.add_row(Vec<CellValue>)- Adds a row of data.set_summary(Vec<CellValue>)-Adds a summary row at the bottom.set_decimal_places(usize)- Sets float precision (default is 2 digits, truncates not rounds).render_to_string(&self) -> String- Renders the table to String (without printing to STDOUT).render()- Prints the table to STDOUT.
Testing
Run unit tests with:
TODO list
- create tag and release for first version
- add CI for Rust in GIthub Actions
- update unit tests
- publish library to cargo repository
- add summary auto aggregates (sum, mul, avg, mean, std_dev, percentile_99)
- add CSV file as input to table to visualize CSV cells
- connect previous features to auto aggregates and CSV view, to calculate aggregates from CSV files
- create bin program for exucure below features in terminal pipeline like
cat salaries.csv | csv2tab --summary sum - add feature to auto refresh table on terminal with defined seconds
- add code test coverage metrics
Contributing
Pull requests, issues, and feedback are welcome! Let’s make ASCII tables beautiful together.