improve cli

This commit is contained in:
Mylloon 2022-08-17 14:56:36 +02:00
parent 182933226e
commit b1adad3519
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,4 +1,4 @@
use clap::{Parser}; use clap::Parser;
use regex::Regex; use regex::Regex;
mod ics; mod ics;
@ -9,16 +9,16 @@ mod utils;
#[derive(Parser)] #[derive(Parser)]
#[clap(version, about, long_about = None)] #[clap(version, about, long_about = None)]
struct Args { struct Args {
/// The class you want to get the timetable /// The class you want to get the timetable, i.e.: L2-A
#[clap(value_parser)] #[clap(value_parser)]
class: String, class: String,
/// The semester you want (useful only in 3rd year) /// The semester you want (useful only in 3rd year, 1-2 use letter in class)
#[clap(short, long, value_parser)] #[clap(short, long, value_parser, value_name = "SEMESTER NUMBER")]
semester: Option<i8>, semester: Option<i8>,
/// Export to iCalendar format (.ics) /// Export to iCalendar format (.ics)
#[clap(short, long)] #[clap(short, long, value_name = "FILE NAME")]
export: Option<String>, export: Option<String>,
} }
@ -53,10 +53,12 @@ async fn main() {
if args.export.is_some() { if args.export.is_some() {
// Export the calendar // Export the calendar
println!("Build the ICS file...");
let builded_timetable = timetable::build(timetable, info);
ics::export(builded_timetable, &args.export.unwrap()); let filename = args.export.unwrap();
println!("Build the ICS file at {}...", filename);
let builded_timetable = timetable::build(timetable, info);
ics::export(builded_timetable, &filename);
} else { } else {
// Show the calendar // Show the calendar
println!("Displaying...") println!("Displaying...")