use crate::{db::{lists_insert, lists_remove, config_change_current_list, config_get_current_list, lists_get}, Modloader, config::Cfg, input::{Input, ListOptions}, /*cmd_update,*/ error::MLE, /*modrinth::MCVersionType*/}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct List { pub id: String, pub mc_version: String, pub modloader: Modloader, pub download_folder: String, } pub async fn list(config: Cfg, input: Input) -> MLE<()> { match input.clone().list_options.unwrap() { ListOptions::Add => { add(config, input) }, ListOptions::Change => { change(config, input) }, ListOptions::Remove => { remove(config, input) }, /* Subcmd::Version => { match version(config, Some(input.args.ok_or("NO_VERSION")?), Some(MCVersionType::Release)).await { Ok(..) => Ok(()), Err(e) => Err(Box::new(e)) } }*/ } } pub fn get_current_list(config: Cfg) -> MLE { let id = config_get_current_list(config.clone())?; lists_get(config, id) } fn add(config: Cfg, input: Input) -> MLE<()> { let id = input.list_id.unwrap(); let mc_version = input.list_mcversion.unwrap(); let mod_loader = input.modloader.unwrap(); let download_folder = input.directory.unwrap(); lists_insert(config, id, mc_version, mod_loader, download_folder) } fn change(config: Cfg, input: Input) -> MLE<()> { //TODO reimplement current list config_change_current_list(config, input.list.unwrap().id) } fn remove(config: Cfg, input: Input) -> MLE<()> { lists_remove(config, input.list.unwrap().id) } /* ///Changing the current lists version and updating it /// #Arguments /// /// * `config` - The current config /// * `args` - All args, to extract the new version async fn version(config: Cfg, args: Option>, version_type: Option) -> MLE<()> { let current_list = lists_get(config.clone(), config_get_current_list(config.clone())?)?; lists_version(config.clone(), String::from(¤t_list.id), String::from(&args.unwrap()[0]))?; //update the list & with -- args cmd_update(config, vec![current_list], true, true, false).await } */