From 96cc5257de09682df345e768dc2a91303f9b36c9 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 3 Nov 2022 21:34:04 +0100 Subject: added update beginnings; init of tests --- src/commands/list.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/commands/list.rs') diff --git a/src/commands/list.rs b/src/commands/list.rs index 6c260ce..3dfe1ad 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -1,12 +1,19 @@ use std::io::{Error, ErrorKind}; -use crate::{db::{insert_list, remove_list, change_list, get_lists, get_current_list}, Modloader, config::Cfg, input::Input}; +use crate::{db::{insert_list, remove_list, change_list, get_lists, get_current_list_id, get_list}, Modloader, config::Cfg, input::Input}; + +#[derive(Clone)] +pub struct List { + pub id: String, + pub mc_version: String, + pub modloader: Modloader, +} pub fn list(config: Cfg, args: Option>) -> Result<(), Box> { if args.is_none() { let lists = get_lists(config.clone())?; - let current_list = get_current_list(config)?; + let current_list = get_current_list_id(config)?; println!("Your lists:\n{}\n-----\nCurrently selected list: \"{}\"", lists.join(",\n"), current_list); return Ok(()); } @@ -29,6 +36,11 @@ pub fn list(config: Cfg, args: Option>) -> Result<(), Box Result> { + let id = get_current_list_id(config.clone())?; + get_list(config, id) +} + fn add(config: Cfg, args: Vec) -> Result<(), Box> { match args.len() { 1 | 2 => Err(Box::new(Error::new(ErrorKind::InvalidInput, "TOO_FEW_ARGUMENTS"))), -- cgit v1.2.3