// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use self_update::cargo_crate_version;
use serde::Deserialize;
use serde::Serialize;
use serde_json::{Map, Result, Value};
use std::collections::{HashMap, HashSet};
use std::io::Seek;
use std::{io::Cursor, path::PathBuf};

//mod ftp;
mod admin;
mod https;
mod java;
mod modpack;
mod prism;
mod sftp;
mod system_dirs;
mod util;

#[derive(Serialize, Deserialize)]
struct ModpackEntry {
    name: String,
    id: String,
}

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

fn main() {
    //modpack::get_modpacks();
    //prism::install_prism();
    tauri::Builder::default()
        .plugin(tauri_plugin_updater::Builder::new().build())
        .plugin(tauri_plugin_process::init())
        .plugin(tauri_plugin_shell::init())
        .plugin(tauri_plugin_dialog::init())
        .invoke_handler(tauri::generate_handler![
            greet,
            modpack::get_modpacks,
            modpack::launch_modpack,
            modpack::get_versions,
            modpack::get_latest_version,
            prism::launch_prism,
            prism::install_prism,
            admin::login,
            admin::drop_session,
            admin::shift_up,
            admin::shift_down,
            admin::add_pack,
            admin::remove_pack,
            admin::update_pack
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
