diff options
author | FxQnLr <[email protected]> | 2023-01-04 13:41:27 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2023-01-04 13:41:27 +0100 |
commit | d0d282de34e77263129770ab28b8ec97d115ba72 (patch) | |
tree | 610ef23afb27b37d6815859bece24cff78c284ef /src/commands/list.rs | |
parent | 9365747f8da3185670780f013d059b3271950f75 (diff) | |
download | modlist-d0d282de34e77263129770ab28b8ec97d115ba72.tar modlist-d0d282de34e77263129770ab28b8ec97d115ba72.tar.gz modlist-d0d282de34e77263129770ab28b8ec97d115ba72.zip |
started version implementation
Diffstat (limited to 'src/commands/list.rs')
-rw-r--r-- | src/commands/list.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/commands/list.rs b/src/commands/list.rs index bc9e67e..585efe2 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use std::io::{Error, ErrorKind}; | 1 | use std::io::{Error, ErrorKind}; |
2 | 2 | ||
3 | use crate::{db::{lists_insert, lists_remove, config_change_current_list, lists_get_all_ids, config_get_current_list, lists_get}, Modloader, config::Cfg, input::{Input, Subcmd}}; | 3 | use crate::{db::{lists_insert, lists_remove, config_change_current_list, lists_get_all_ids, config_get_current_list, lists_get, lists_version}, Modloader, config::Cfg, input::{Input, Subcmd}}; |
4 | 4 | ||
5 | #[derive(Debug, Clone, PartialEq, Eq)] | 5 | #[derive(Debug, Clone, PartialEq, Eq)] |
6 | pub struct List { | 6 | pub struct List { |
@@ -10,7 +10,7 @@ pub struct List { | |||
10 | pub download_folder: String, | 10 | pub download_folder: String, |
11 | } | 11 | } |
12 | 12 | ||
13 | pub fn list(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { | 13 | pub async fn list(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { |
14 | 14 | ||
15 | match input.subcommand.ok_or("")? { | 15 | match input.subcommand.ok_or("")? { |
16 | Subcmd::Add => { | 16 | Subcmd::Add => { |
@@ -22,6 +22,9 @@ pub fn list(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> | |||
22 | Subcmd::Remove => { | 22 | Subcmd::Remove => { |
23 | remove(config, input.args.ok_or("")?) | 23 | remove(config, input.args.ok_or("")?) |
24 | }, | 24 | }, |
25 | Subcmd::Version => { | ||
26 | version(config, input.args.ok_or("NO_VERSION")?) | ||
27 | } | ||
25 | _ => { | 28 | _ => { |
26 | Err(Box::new(Error::new(ErrorKind::InvalidInput, "WRONG_SUBCOMMAND"))) | 29 | Err(Box::new(Error::new(ErrorKind::InvalidInput, "WRONG_SUBCOMMAND"))) |
27 | } | 30 | } |
@@ -70,3 +73,8 @@ fn remove(config: Cfg, args: Vec<String>) -> Result<(), Box<dyn std::error::Erro | |||
70 | _ => panic!("list arguments should never be zero or lower"), | 73 | _ => panic!("list arguments should never be zero or lower"), |
71 | } | 74 | } |
72 | } | 75 | } |
76 | |||
77 | fn version(config: Cfg, args: Vec<String>) -> Result<(), Box<dyn std::error::Error>> { | ||
78 | lists_version(config.clone(), config_get_current_list(config.clone())?, String::from(&args[0])) | ||
79 | //update the list & with -- args | ||
80 | } | ||