https://github.com/j-f-liu/ascii-table
Forked from https://gitlab.com/d5b4b2/ascii-table
https://github.com/j-f-liu/ascii-table
Last synced: 3 months ago
JSON representation
Forked from https://gitlab.com/d5b4b2/ascii-table
- Host: GitHub
- URL: https://github.com/j-f-liu/ascii-table
- Owner: J-F-Liu
- License: gpl-3.0
- Created: 2020-09-10T02:52:22.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-10T03:35:54.000Z (over 4 years ago)
- Last Synced: 2024-12-28T19:29:42.304Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 57.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: COPYING
Awesome Lists containing this project
README
# ascii-table
Print ASCII tables to the terminal.
## Example
```
use ascii_table::AsciiTable;let ascii_table = AsciiTable::default();
let data = vec![&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]];
ascii_table.print(data);
// ┌───┬───┬───┐
// │ 1 │ 2 │ 3 │
// │ 4 │ 5 │ 6 │
// │ 7 │ 8 │ 9 │
// └───┴───┴───┘
```## Example
```
use std::fmt::Display;
use ascii_table::{AsciiTable, Column, Align};let mut ascii_table = AsciiTable::default();
ascii_table.max_width = 26;let mut column = Column::default();
column.header = "H1".into();
column.align = Align::Left;
ascii_table.columns.insert(0, column);let mut column = Column::default();
column.header = "H2".into();
column.align = Align::Center;
ascii_table.columns.insert(1, column);let mut column = Column::default();
column.header = "H3".into();
column.align = Align::Right;
ascii_table.columns.insert(2, column);let data: Vec> = vec![
vec![&'v', &'v', &'v'],
vec![&123, &456, &789, &"abcdef"]
];
ascii_table.print(data);
// ┌─────┬─────┬─────┬──────┐
// │ H1 │ H2 │ H3 │ │
// ├─────┼─────┼─────┼──────┤
// │ v │ v │ v │ │
// │ 123 │ 456 │ 789 │ abc+ │
// └─────┴─────┴─────┴──────┘
```