From 0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sat, 5 Nov 2022 21:53:24 +0100 Subject: added setup & download; direct input --- src/input.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index e0c9ae9..c7e82d9 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,5 +1,5 @@ -use std::io::{stdin, Error, ErrorKind}; -use crate::{config::Cfg, list, modification, update}; +use std::{io::{Error, ErrorKind}, env}; +use crate::{config::Cfg, list, modification, update, setup, download}; #[derive(Debug, PartialEq, Eq)] pub struct Input { @@ -32,12 +32,14 @@ impl Input { } pub async fn get_input(config: Cfg) -> Result<(), Box> { - let mut user_input = String::new(); - stdin() - .read_line(&mut user_input) - .expect("ERROR"); + let mut args: Vec = env::args().collect(); + dbg!(&args); + args.reverse(); + args.pop(); + args.reverse(); + dbg!(&args); - let input = Input::from(user_input.trim().to_string())?; + let input = Input::from(args.join(" "))?; match input.command.as_str() { "mod" => { @@ -49,6 +51,12 @@ pub async fn get_input(config: Cfg) -> Result<(), Box> { "update" => { update(config).await }, + "setup" => { + setup(config).await + }, + "download" => { + download(config).await + }, _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), } } -- cgit v1.2.3