summaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2022-11-03 21:34:04 +0100
committerfxqnlr <[email protected]>2022-11-03 21:34:04 +0100
commit96cc5257de09682df345e768dc2a91303f9b36c9 (patch)
treef505d14c581e2bef4cfe222bd1069661bedd22e0 /src/input.rs
parentb125dfd03084fff47ab8e90d002c6699b762d998 (diff)
downloadmodlist-96cc5257de09682df345e768dc2a91303f9b36c9.tar
modlist-96cc5257de09682df345e768dc2a91303f9b36c9.tar.gz
modlist-96cc5257de09682df345e768dc2a91303f9b36c9.zip
added update beginnings; init of tests
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/input.rs b/src/input.rs
index 061f1fd..0c13e67 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -1,5 +1,5 @@
1use std::io::{stdin, Error, ErrorKind}; 1use std::io::{stdin, Error, ErrorKind};
2use crate::{add, config::Cfg, list}; 2use crate::{config::Cfg, list, modification, update};
3 3
4pub struct Input { 4pub struct Input {
5 pub command: String, 5 pub command: String,
@@ -41,15 +41,15 @@ pub async fn get_input(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
41 let input = Input::from(user_input.trim().to_string())?; 41 let input = Input::from(user_input.trim().to_string())?;
42 42
43 match input.command.as_str() { 43 match input.command.as_str() {
44 "add" => { 44 "mod" => {
45 if input.args == None { return Err(Box::new(Error::new(ErrorKind::InvalidInput, "TOO_FEW_ARGUMENTS"))) }; 45 modification(config, input.args).await
46 if input.args.as_ref().unwrap().len() != 1 { return Err(Box::new(Error::new(ErrorKind::InvalidInput, "TOO_MANY_ARGUMENTS"))) };
47 add(config, input.args.unwrap()[0].to_string()).await?;
48 Ok(())
49 }, 46 },
50 "list" => { 47 "list" => {
51 list(config, input.args) 48 list(config, input.args)
52 }, 49 },
50 "update" => {
51 update(config).await
52 },
53 _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), 53 _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))),
54 } 54 }
55} 55}