From 96cc5257de09682df345e768dc2a91303f9b36c9 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 3 Nov 2022 21:34:04 +0100 Subject: added update beginnings; init of tests --- src/input.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/input.rs') 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 @@ use std::io::{stdin, Error, ErrorKind}; -use crate::{add, config::Cfg, list}; +use crate::{config::Cfg, list, modification, update}; pub struct Input { pub command: String, @@ -41,15 +41,15 @@ pub async fn get_input(config: Cfg) -> Result<(), Box> { let input = Input::from(user_input.trim().to_string())?; match input.command.as_str() { - "add" => { - if input.args == None { return Err(Box::new(Error::new(ErrorKind::InvalidInput, "TOO_FEW_ARGUMENTS"))) }; - if input.args.as_ref().unwrap().len() != 1 { return Err(Box::new(Error::new(ErrorKind::InvalidInput, "TOO_MANY_ARGUMENTS"))) }; - add(config, input.args.unwrap()[0].to_string()).await?; - Ok(()) + "mod" => { + modification(config, input.args).await }, "list" => { list(config, input.args) }, + "update" => { + update(config).await + }, _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), } } -- cgit v1.2.3