Archived
1
0
Fork 0
forked from Anri/cal8tor

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;
mod ics;
@ -9,16 +9,16 @@ mod utils;
#[derive(Parser)]
#[clap(version, about, long_about = None)]
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)]
class: String,
/// The semester you want (useful only in 3rd year)
#[clap(short, long, value_parser)]
/// The semester you want (useful only in 3rd year, 1-2 use letter in class)
#[clap(short, long, value_parser, value_name = "SEMESTER NUMBER")]
semester: Option<i8>,
/// Export to iCalendar format (.ics)
#[clap(short, long)]
#[clap(short, long, value_name = "FILE NAME")]
export: Option<String>,
}
@ -53,10 +53,12 @@ async fn main() {
if args.export.is_some() {
// 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 {
// Show the calendar
println!("Displaying...")