From b125dfd03084fff47ab8e90d002c6699b762d998 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 1 Nov 2022 23:00:45 +0100 Subject: added list stuff + beginnings of mods --- src/input.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index 689389e..061f1fd 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,5 +1,5 @@ use std::io::{stdin, Error, ErrorKind}; -use crate::{add, config::Cfg}; +use crate::{add, config::Cfg, list}; pub struct Input { pub command: String, @@ -9,14 +9,9 @@ pub struct Input { impl Input { pub fn from(string: String) -> Result> { let mut split: Vec<&str> = string.split(' ').collect(); - let command: String; let mut args: Option> = None; - if split[0].is_empty() { split.remove(0); }; - - dbg!(&split); - match split.len() { 0 => { Err(Box::new(Error::new(ErrorKind::InvalidInput, "NO_ARGS"))) } 1 => Ok( Input { command: split[0].to_string(), args }), @@ -43,8 +38,6 @@ pub async fn get_input(config: Cfg) -> Result<(), Box> { .read_line(&mut user_input) .expect("ERROR"); - dbg!(&user_input); - let input = Input::from(user_input.trim().to_string())?; match input.command.as_str() { @@ -54,6 +47,9 @@ pub async fn get_input(config: Cfg) -> Result<(), Box> { add(config, input.args.unwrap()[0].to_string()).await?; Ok(()) }, + "list" => { + list(config, input.args) + }, _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), } } -- cgit v1.2.3