diff options
author | fxqnlr <[email protected]> | 2023-05-09 20:34:09 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-05-09 20:34:09 +0200 |
commit | 9063a041f6b2e72f6e4a861c77ac16065dd5378b (patch) | |
tree | 03d34dfe9ff05de2dd74d3afe1cde87712f1b59a /src/main.rs | |
parent | 0c7ba29d3e17c47e5fc9cffe78c28a0019d453b7 (diff) | |
download | modlist-9063a041f6b2e72f6e4a861c77ac16065dd5378b.tar modlist-9063a041f6b2e72f6e4a861c77ac16065dd5378b.tar.gz modlist-9063a041f6b2e72f6e4a861c77ac16065dd5378b.zip |
add list toggles to update and download;
add mod remove output and fix errors
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 36 |
1 files changed, 29 insertions, 7 deletions
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 { | |||
44 | /// remove disabled versions | 44 | /// remove disabled versions |
45 | #[arg(short, long)] | 45 | #[arg(short, long)] |
46 | remove: bool, | 46 | remove: bool, |
47 | |||
48 | /// optional List selection, else default list will be used | ||
49 | #[arg(short, long)] | ||
50 | list: Option<String>, | ||
47 | }, | 51 | }, |
48 | Update { | 52 | Update { |
49 | /// download all lists | 53 | /// download all lists |
@@ -61,6 +65,10 @@ enum Commands { | |||
61 | /// delete disabled versions | 65 | /// delete disabled versions |
62 | #[arg(short, long)] | 66 | #[arg(short, long)] |
63 | remove: bool, | 67 | remove: bool, |
68 | |||
69 | /// optional List selection, else default list will be used | ||
70 | #[arg(short, long)] | ||
71 | list: Option<String>, | ||
64 | }, | 72 | }, |
65 | Import { | 73 | Import { |
66 | #[arg(short, long)] | 74 | #[arg(short, long)] |
@@ -180,8 +188,6 @@ async fn main() { | |||
180 | mod_add(config, vec![marked_id], listf, download, lock).await | 188 | mod_add(config, vec![marked_id], listf, download, lock).await |
181 | } | 189 | } |
182 | ModCommands::Remove { id, list } => { | 190 | ModCommands::Remove { id, list } => { |
183 | //TODO add output | ||
184 | //TODO add success even if no file found | ||
185 | let listf = match list { | 191 | let listf = match list { |
186 | Some(list) => lists_get(config.clone(), list).unwrap(), | 192 | Some(list) => lists_get(config.clone(), list).unwrap(), |
187 | None => lists_get( | 193 | None => lists_get( |
@@ -228,12 +234,12 @@ async fn main() { | |||
228 | } => list_version(config, id, version, download, remove).await, | 234 | } => list_version(config, id, version, download, remove).await, |
229 | } | 235 | } |
230 | } | 236 | } |
231 | //TODO a add specific list | ||
232 | Commands::Update { | 237 | Commands::Update { |
233 | all, | 238 | all, |
234 | download, | 239 | download, |
235 | clean, | 240 | clean, |
236 | remove, | 241 | remove, |
242 | list | ||
237 | } => { | 243 | } => { |
238 | let mut liststack: Vec<List> = vec![]; | 244 | let mut liststack: Vec<List> = vec![]; |
239 | if all { | 245 | if all { |
@@ -242,14 +248,30 @@ async fn main() { | |||
242 | liststack.push(lists_get(config.clone(), id).unwrap()); | 248 | liststack.push(lists_get(config.clone(), id).unwrap()); |
243 | } | 249 | } |
244 | } else { | 250 | } else { |
245 | let current = get_current_list(config.clone()).unwrap(); | 251 | let current = match list { |
246 | println!("Update list {}:", current.id); | 252 | Some(l) => lists_get(config.clone(), l).unwrap(), |
253 | None => get_current_list(config.clone()).unwrap(), | ||
254 | }; | ||
247 | liststack.push(current) | 255 | liststack.push(current) |
248 | } | 256 | } |
249 | update(config, liststack, clean, download, remove).await | 257 | update(config, liststack, clean, download, remove).await |
250 | } | 258 | } |
251 | //TODO add specific list | 259 | Commands::Download { all, clean, remove, list } => { |
252 | Commands::Download { all, clean, remove } => download(config, all, clean, remove).await, | 260 | let mut liststack: Vec<List> = vec![]; |
261 | if all { | ||
262 | let list_ids = lists_get_all_ids(config.clone()).unwrap(); | ||
263 | for id in list_ids { | ||
264 | liststack.push(lists_get(config.clone(), id).unwrap()); | ||
265 | } | ||
266 | } else { | ||
267 | let current = match list { | ||
268 | Some(l) => lists_get(config.clone(), l).unwrap(), | ||
269 | None => get_current_list(config.clone()).unwrap(), | ||
270 | }; | ||
271 | liststack.push(current) | ||
272 | } | ||
273 | download(config, liststack, clean, remove).await | ||
274 | }, | ||
253 | Commands::Import { file, download } => { | 275 | Commands::Import { file, download } => { |
254 | let filestr: String = match file { | 276 | let filestr: String = match file { |
255 | Some(args) => args, | 277 | Some(args) => args, |