From 29117f7e28e8b678252d10855e355d18dbe2b93b Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 18 Aug 2022 01:16:51 +0200 Subject: [PATCH] show days --- src/timetable.rs | 3 ++- src/timetable/models.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/timetable.rs b/src/timetable.rs index 5bd9895..107530d 100644 --- a/src/timetable.rs +++ b/src/timetable.rs @@ -1,6 +1,7 @@ use chrono::{Datelike, Duration, TimeZone, Utc}; use regex::Regex; use scraper::{Html, Selector}; +use tabled::{Table, Style}; pub mod models; /// Fetch the timetable for a class @@ -322,5 +323,5 @@ fn get_semester(semester: Option, letter: Option) -> i8 { /// Display the timetable pub fn display(timetable: (Vec, (usize, Vec))) { - println!("{:#?}", timetable); + println!("{}", Table::new(timetable.1 .1).with(Style::modern()).to_string()); } diff --git a/src/timetable/models.rs b/src/timetable/models.rs index 612e3d8..6297340 100644 --- a/src/timetable/models.rs +++ b/src/timetable/models.rs @@ -35,10 +35,11 @@ pub struct Course { pub dtend: Option>, } -#[derive(Debug)] +#[derive(Tabled, Debug)] pub struct Day { /// Day's name pub name: String, /// Ordered list of all the courses of the day + #[tabled(skip)] pub courses: Vec>, }