Replace comfy-table with prettytable
This reduces the amount dependencies
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -1,8 +1,5 @@
|
||||
use chrono::{Datelike, Local};
|
||||
use comfy_table::modifiers::UTF8_ROUND_CORNERS;
|
||||
use comfy_table::presets::UTF8_FULL;
|
||||
use comfy_table::*;
|
||||
use mensa::Mealplan;
|
||||
use chrono::Local;
|
||||
use prettytable::{row, Cell, Row, Table};
|
||||
|
||||
mod cli;
|
||||
mod mensa;
|
||||
@@ -65,21 +62,15 @@ fn exec_arg_helper(args: &cli::Args, m: &dyn mensa::Mealplan) {
|
||||
fn table_short(data: Vec<(&str, String, &str)>) {
|
||||
let mut table = Table::new();
|
||||
|
||||
//let mut data_cells = data.iter().map(|x| vec![Cell::new(x.0), Cell::new(&x.1), Cell::new(x.2)]).collect::<Vec<Vec<Cell>>>();
|
||||
|
||||
table
|
||||
.load_preset(UTF8_FULL)
|
||||
.apply_modifier(UTF8_ROUND_CORNERS)
|
||||
.set_content_arrangement(ContentArrangement::Dynamic)
|
||||
//.set_width(40)
|
||||
.set_header(vec!["Art", "Beschreibung", "Preis (Student)"]);
|
||||
table.add_row(row!["Art", "Beschreibung", "Preis (Student)"]);
|
||||
|
||||
for d in data.iter() {
|
||||
table.add_row(vec![Cell::new(d.0), Cell::new(&d.1), Cell::new(d.2)]);
|
||||
table.add_row(Row::new(vec![
|
||||
Cell::new(d.0),
|
||||
Cell::new(&d.1),
|
||||
Cell::new(d.2).style_spec("r"),
|
||||
]));
|
||||
}
|
||||
// Set the default alignment for the third column to right
|
||||
let column = table.column_mut(2).expect("Our table has three columns");
|
||||
column.set_cell_alignment(CellAlignment::Right);
|
||||
|
||||
println!("{table}");
|
||||
table.printstd();
|
||||
}
|
||||
|
Reference in New Issue
Block a user