* use String instead of &str

* WIP display fn
This commit is contained in:
Mylloon 2022-08-17 17:08:30 +02:00
parent 076ed15d2a
commit 829b4ef7b1
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 10 additions and 5 deletions

View file

@ -5,7 +5,7 @@ use ics::{
Event, ICalendar, Standard,
};
pub fn export(courses: Vec<crate::timetable::models::Course>, filename: &str) {
pub fn export(courses: Vec<crate::timetable::models::Course>, filename: String) {
let mut calendar = ICalendar::new("2.0", "cal8tor");
// Add Europe/Paris timezone
@ -58,7 +58,7 @@ pub fn export(courses: Vec<crate::timetable::models::Course>, filename: &str) {
}
calendar
.save_file(match filename.to_string() {
.save_file(match filename {
x if x.ends_with(".ics") => x,
x => format!("{}.ics", x),
})

View file

@ -53,14 +53,14 @@ async fn main() {
if args.export.is_some() {
// Export the calendar
let filename = args.export.unwrap();
println!("Build the ICS file at {}...", filename);
let builded_timetable = timetable::build(timetable, info);
ics::export(builded_timetable, &filename);
ics::export(builded_timetable, filename);
} else {
// Show the calendar
println!("Displaying...")
println!("Displaying...");
timetable::display();
}
}

View file

@ -320,3 +320,8 @@ fn get_semester(semester: Option<i8>, letter: Option<char>) -> i8 {
},
}
}
/// Display the timetable
pub fn display() {
todo!("WIP")
}