use crate::error::AppError;
use crate::groups::{GroupsFile, MdFileEntry};

#[tauri::command]
pub fn groups_load() -> Result<GroupsFile, AppError> {
    crate::groups::load_groups().map_err(AppError::config)
}

#[tauri::command]
pub fn groups_save(config: GroupsFile) -> Result<(), AppError> {
    crate::groups::save_groups(&config).map_err(AppError::config)
}

#[tauri::command]
pub fn discover_markdown_files(cwd: String) -> Result<Vec<MdFileEntry>, AppError> {
    crate::groups::discover_markdown_files(&cwd).map_err(AppError::filesystem)
}
