tabprinter
tabprinter is a Rust library for creating and printing formatted tables in the terminal. It supports various table styles and offers both color and non-color output options.
Features
- Multiple table styles: Simple, Grid, FancyGrid, Clean, Round, Banner, Block, and Amiga
- Customizable column widths and alignments
- Color output support (using termcolor)
- Easy-to-use API for creating and populating tables
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Here's a basic example of how to use tabprinter:
use ;
This will output:
| | | |
| | | |
| | | |
Table Styles
tabprinter supports the following table styles:
Simple: No bordersGrid: ASCII bordersFancyGrid: Unicode bordersClean: Minimal bordersRound: Rounded cornersBanner: Top and bottom bannersBlock: Block-style bordersAmiga: Amiga-inspired style (color output only)
To change the style, simply use a different TableStyle when creating the table:
let mut table = new;
Color Output
To use color output, use the print_color method instead of print:
use ;
let mut stdout = stdout;
table.print_color.unwrap;
Examples
Check out the examples directory for more usage examples:
basic_usage.rs: Demonstrates basic table creation and printingdifferent_styles.rs: Shows all available table stylescustom_data.rs: Example of using custom data structures with tables
To run an example:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.