use anyhow::Result;
use error::MDTodoError;
use std::path::Path;
use todo::Todo;
pub mod error;
mod md_reader;
mod md_writer;
pub mod todo;
pub fn get_todos_from_path(dir: &dyn AsRef<Path>) -> Result<Vec<Todo>> {
if !dir.as_ref().is_dir() {
return Err(anyhow::Error::new(MDTodoError::NotADir));
}
md_reader::get_todos_from_dir(dir.as_ref())
}
pub fn toggle_todo(todo: &mut Todo) -> Result<()> {
md_writer::toggle_todo(todo)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should_panic]
fn test_invalid_path() {
get_todos_from_path(&"thisPath/ShouldNotExist32/2/013".to_string()).unwrap();
}
}