1
use aetolia::prelude::*;
2

            
3
fn main() {
4
    let file_path = std::env::args()
5
        .nth(1)
6
        .expect("No file provided, should be the first argument");
7

            
8
    let file = std::fs::File::open(&file_path).expect("Could not open file");
9
    let calendar = load_ical(file).expect("Failed to load iCalendar data");
10

            
11
    for (index, object) in calendar.iter().enumerate() {
12
        let errors = validate_model(object).expect("Failed to validate iCalendar data");
13
        println!("Ran validation on object at index: {:?}", index);
14

            
15
        for error in &errors {
16
            if error.severity == ICalendarErrorSeverity::Warning {
17
                println!("Warning: {}", error);
18
            } else {
19
                println!("Error: {}", error);
20
            }
21
        }
22

            
23
        if errors
24
            .iter()
25
            .filter(|e| e.severity == ICalendarErrorSeverity::Error)
26
            .count()
27
            == 0
28
        {
29
            println!("Object is valid");
30
        }
31
    }
32
}