Crate term_table
source ·Expand description
The purpose of term-table is to make it easy for CLI apps to display data in a table format
§Example
Here is an example of how to create a simple table
use term_table::table_cell::TableCell;
use term_table::row::Row;
use term_table::{Table, TableStyle, rows, row};
let mut table = Table::builder()
.max_column_width(40)
.style(TableStyle::extended())
.rows(rows![
row![
TableCell::builder("This is some centered text")
.col_span(2)
.alignment(term_table::table_cell::Alignment::Center)
.build(),
],
row![
"This is left aligned text",
TableCell::builder("This is right aligned text")
.alignment(term_table::table_cell::Alignment::Right)
.build(),
],
row![
"This is left aligned text",
TableCell::builder("This is right aligned text")
.alignment(term_table::table_cell::Alignment::Right)
.build(),
],
row![
TableCell::builder("This is some really really really really really really really really really that is going to wrap to the next line")
.col_span(2)
.build(),
],
])
.build();
println!("{}", table.render());
§This is the result
╔═════════════════════════════════════════════════════════════════════════════════╗ ║ This is some centered text ║ ╠════════════════════════════════════════╦════════════════════════════════════════╣ ║ This is left aligned text ║ This is right aligned text ║ ╠════════════════════════════════════════╬════════════════════════════════════════╣ ║ This is left aligned text ║ This is right aligned text ║ ╠════════════════════════════════════════╩════════════════════════════════════════╣ ║ This is some really really really really really really really really really tha ║ ║ t is going to wrap to the next line ║ ╚═════════════════════════════════════════════════════════════════════════════════╝
Modules§
Macros§
Structs§
- A set of rows containing data
- Used to create non-mutable tables
- A set of characters which make up a table style
Enums§
- Represents the vertical position of a row