mod filters; mod git; use std::path::PathBuf; /// The repository folder: the first command line argument, or the current folder. struct RepoArg(PathBuf); #[tauri::command] fn load_repo(arg: tauri::State) -> Result { git::load(&arg.0) } #[tauri::command] fn load_filters(repo: String) -> Result { filters::load(&repo) } #[tauri::command] fn save_filters(repo: String, value: serde_json::Value) -> Result<(), String> { filters::save(&repo, value) } #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { let path = std::env::args_os() .nth(1) .map(PathBuf::from) .unwrap_or_else(|| std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))); tauri::Builder::default() .plugin(tauri_plugin_clipboard_manager::init()) .manage(RepoArg(path)) .invoke_handler(tauri::generate_handler![load_repo, load_filters, save_filters]) .run(tauri::generate_context!()) .expect("error while running tauri application"); }