CLI Tables
This is a simple Rust library for generating ASCII tables in a CLI application.
Usage
- Add
cli-tablesto yourCargo.tomlfile:
cli-tables = "0.1.0"
- Import the Table struct:
use Table;
- Create a new
Table:
let mut table = new;
- Create the row that you want to display in the table:
let header = vec!;
- Add rows with the
push_rowfunction:
table.push_row;
- Print the table with the
to_stringfunction to the interface:
println!;
- The table will look like this:
+---+------------+-----------+---------------+----------------+
| # | First Name | Last Name | Date of Birth | TV Show |
+---+------------+-----------+---------------+----------------+
| 0 | Pedro | Pascal | 1996-07-28 | The Last of Us |
| 1 | Belle | Ramsey | 1991-09-17 | The Last of Us |
| 3 | Scott | Shepherd | 1990-04-20 | The Last of Us |
| 4 | Nick | Offerman | 1970-06-26 | The Last of Us |
+---+------------+-----------+---------------+----------------+