summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main.rs37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index be3f808..ee7686e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -104,7 +104,7 @@ impl fmt::Display for Course<'_> {
 
 fn main() {
     tracing_subscriber::fmt()
-        .with_max_level(LevelFilter::ERROR)
+        .with_max_level(LevelFilter::INFO)
         .init();
 
     let html = include_str!("../courses.html");
@@ -214,9 +214,38 @@ fn main() {
 
                 working_course.points = points;
 
-                // if let Some(requirements) = details_split.last() {
-                //     requirements.split(|c|)
-                // }
+                if let Some(requirements) = details_split.last().map(|s| s.trim()) {
+                    if requirements.starts_with("(X)") {
+                        working_course.restrictions = requirements[4..]
+                            .split(&[';', ','])
+                            .map(str::trim)
+                            .map(str::to_owned)
+                            .collect::<Vec<String>>();
+                    } else {
+                        let requirements = &requirements[4..].split(" (X) ").collect::<Vec<&str>>();
+
+                        working_course.prerequisites = requirements
+                            .first()
+                            .unwrap()
+                            .split(&[',', ';'])
+                            .map(str::trim)
+                            .filter(|s| !s.is_empty())
+                            .map(str::to_owned)
+                            .collect();
+
+                        if requirements.len() > 1 {
+                            working_course.restrictions = requirements
+                                .last()
+                                .unwrap()
+                                .split(&[',', ';'])
+                                .map(str::trim)
+                                .map(str::to_owned)
+                                .collect();
+                        }
+                    }
+
+                    info!("{requirements}");
+                }
             }
         }
     }