summaryrefslogtreecommitdiff
path: root/src/commands/list.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2023-01-04 13:41:27 +0100
committerFxQnLr <[email protected]>2023-01-04 13:41:27 +0100
commitd0d282de34e77263129770ab28b8ec97d115ba72 (patch)
tree610ef23afb27b37d6815859bece24cff78c284ef /src/commands/list.rs
parent9365747f8da3185670780f013d059b3271950f75 (diff)
downloadmodlist-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.rs12
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 @@
1use std::io::{Error, ErrorKind}; 1use std::io::{Error, ErrorKind};
2 2
3use 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}}; 3use 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)]
6pub struct List { 6pub struct List {
@@ -10,7 +10,7 @@ pub struct List {
10 pub download_folder: String, 10 pub download_folder: String,
11} 11}
12 12
13pub fn list(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { 13pub 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
77fn 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}