1use anyhow::Result;
2use error::MDTodoError;
3use std::path::Path;
4use todo::Todo;
5
6pub mod error;
7mod md_reader;
8mod md_writer;
9pub mod todo;
10
11pub fn get_todos_from_path(dir: &dyn AsRef<Path>) -> Result<Vec<Todo>> {
14 if !dir.as_ref().is_dir() {
15 return Err(anyhow::Error::new(MDTodoError::NotADir));
16 }
17
18 md_reader::get_todos_from_dir(dir.as_ref())
19}
20
21pub fn toggle_todo(todo: &mut Todo) -> Result<()> {
27 md_writer::toggle_todo(todo)
28}
29
30#[cfg(test)]
31mod tests {
32
33 use super::*;
34
35 #[test]
36 #[should_panic]
37 fn test_invalid_path() {
38 get_todos_from_path(&"thisPath/ShouldNotExist32/2/013".to_string()).unwrap();
39 }
40}