Skip to content

Commit

Permalink
Add parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemppis3 committed Jul 10, 2024
1 parent f5da62f commit 402f8c1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,17 @@ impl WeeksTasksOutput {
WeeksTasksOutput { name, output_type }
}
}

pub fn read_toml_content_from_file(filepath: &str) -> Result<String, Box<dyn Error>> {
let mut file = fs::File::open(filepath)?;
let mut file_content = String::new();
file.read_to_string(&mut file_content)?;
Ok(file_content)
}


//TODO: Add warnings for unspecified fields
pub fn toml_content(file_content: String) -> Result<CourseConfiguration, Box<dyn Error>> {
let course_config: CourseConfiguration = toml::from_str(&file_content)?;
Ok(course_config)
}

0 comments on commit 402f8c1

Please sign in to comment.