cli-tables 0.2.0

A simple Rust library for generating ASCII tables in a CLI application.
Documentation

CLI Tables

This is a simple Rust library for generating ASCII tables in a CLI application.

Usage

  1. Add cli-tables to your Cargo.toml file:
[dependencies]
cli-tables = "0.1.0"
  1. Import the Table struct:
use cli_tables::Table;
  1. Create a new Table:
let mut table = Table::new();
  1. Create the row that you want to display in the table:
let header = vec!["#", "First Name", "Last Name", "Date of Birth", "TV Show"];
  1. Add rows with the push_row function:
table.push_row(&header);
  1. Print the table with the to_string function to the interface:
println!("{}", table.to_string());
  1. 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 |
+---+------------+-----------+---------------+----------------+