From 9063a041f6b2e72f6e4a861c77ac16065dd5378b Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 9 May 2023 20:34:09 +0200 Subject: add list toggles to update and download; add mod remove output and fix errors --- src/main.rs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 3bc2ba0..2db304b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,10 @@ enum Commands { /// remove disabled versions #[arg(short, long)] remove: bool, + + /// optional List selection, else default list will be used + #[arg(short, long)] + list: Option, }, Update { /// download all lists @@ -61,6 +65,10 @@ enum Commands { /// delete disabled versions #[arg(short, long)] remove: bool, + + /// optional List selection, else default list will be used + #[arg(short, long)] + list: Option, }, Import { #[arg(short, long)] @@ -180,8 +188,6 @@ async fn main() { mod_add(config, vec![marked_id], listf, download, lock).await } ModCommands::Remove { id, list } => { - //TODO add output - //TODO add success even if no file found let listf = match list { Some(list) => lists_get(config.clone(), list).unwrap(), None => lists_get( @@ -228,12 +234,12 @@ async fn main() { } => list_version(config, id, version, download, remove).await, } } - //TODO a add specific list Commands::Update { all, download, clean, remove, + list } => { let mut liststack: Vec = vec![]; if all { @@ -242,14 +248,30 @@ async fn main() { liststack.push(lists_get(config.clone(), id).unwrap()); } } else { - let current = get_current_list(config.clone()).unwrap(); - println!("Update list {}:", current.id); + let current = match list { + Some(l) => lists_get(config.clone(), l).unwrap(), + None => get_current_list(config.clone()).unwrap(), + }; liststack.push(current) } update(config, liststack, clean, download, remove).await } - //TODO add specific list - Commands::Download { all, clean, remove } => download(config, all, clean, remove).await, + Commands::Download { all, clean, remove, list } => { + let mut liststack: Vec = vec![]; + if all { + let list_ids = lists_get_all_ids(config.clone()).unwrap(); + for id in list_ids { + liststack.push(lists_get(config.clone(), id).unwrap()); + } + } else { + let current = match list { + Some(l) => lists_get(config.clone(), l).unwrap(), + None => get_current_list(config.clone()).unwrap(), + }; + liststack.push(current) + } + download(config, liststack, clean, remove).await + }, Commands::Import { file, download } => { let filestr: String = match file { Some(args) => args, -- cgit v1.2.3