Archived
1
0
Fork 0
forked from Anri/cal8tor

return the new filename for verbose

This commit is contained in:
Mylloon 2023-04-23 00:07:25 +02:00
parent 09a83c2b66
commit 0a5dd3c8f0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 13 additions and 12 deletions

2
Cargo.lock generated
View file

@ -70,7 +70,7 @@ checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c"
[[package]] [[package]]
name = "cal8tor" name = "cal8tor"
version = "0.4.2" version = "0.4.3"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "cal8tor" name = "cal8tor"
version = "0.4.2" version = "0.4.3"
authors = ["Mylloon"] authors = ["Mylloon"]
edition = "2021" edition = "2021"
description = "Extractor of the calendar of the IT degree of university Paris 8" description = "Extractor of the calendar of the IT degree of university Paris 8"

View file

@ -5,7 +5,7 @@ use ics::{
Event, ICalendar, Standard, Event, ICalendar, Standard,
}; };
pub fn export(courses: Vec<crate::timetable::models::Course>, filename: String) { pub fn export(courses: Vec<crate::timetable::models::Course>, filename: &mut String) {
let mut calendar = ICalendar::new("2.0", "cal8tor"); let mut calendar = ICalendar::new("2.0", "cal8tor");
// Add Europe/Paris timezone // Add Europe/Paris timezone
@ -61,12 +61,12 @@ pub fn export(courses: Vec<crate::timetable::models::Course>, filename: String)
calendar.add_event(event); calendar.add_event(event);
} }
calendar // Add the extension if needed
.save_file(match filename { if !filename.ends_with(".ics") {
x if x.ends_with(".ics") => x, *filename = format!("{}.ics", filename)
x => format!("{}.ics", x), };
})
.unwrap(); calendar.save_file(filename).unwrap();
} }
/// Transform the datetime from chrono to the ICS format /// Transform the datetime from chrono to the ICS format

View file

@ -66,11 +66,12 @@ async fn main() {
if args.export.is_some() { if args.export.is_some() {
// Export the calendar // Export the calendar
let filename = args.export.unwrap(); let mut filename = args.export.unwrap();
println!("Fichier .ICS construit et exporté ici : {}...", filename);
let builded_timetable = timetable::build(timetable, info); let builded_timetable = timetable::build(timetable, info);
ics::export(builded_timetable, filename); ics::export(builded_timetable, &mut filename);
println!("Fichier .ICS construit et exporté => {}", filename);
} else { } else {
// Show the calendar // Show the calendar
println!("Affichage..."); println!("Affichage...");