diff options
author | fxqnlr <[email protected]> | 2022-11-05 21:53:24 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-05 21:53:24 +0100 |
commit | 0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd (patch) | |
tree | 6262c397c500834cf6a06059394ac51328de3aed /src/input.rs | |
parent | 5d50f446a1a4612c0c931bdbc61f945760392f29 (diff) | |
download | modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar.gz modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.zip |
added setup & download; direct input
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 22 |
1 files changed, 15 insertions, 7 deletions
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 @@ | |||
1 | use std::io::{stdin, Error, ErrorKind}; | 1 | use std::{io::{Error, ErrorKind}, env}; |
2 | use crate::{config::Cfg, list, modification, update}; | 2 | use crate::{config::Cfg, list, modification, update, setup, download}; |
3 | 3 | ||
4 | #[derive(Debug, PartialEq, Eq)] | 4 | #[derive(Debug, PartialEq, Eq)] |
5 | pub struct Input { | 5 | pub struct Input { |
@@ -32,12 +32,14 @@ impl Input { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | pub async fn get_input(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { | 34 | pub async fn get_input(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { |
35 | let mut user_input = String::new(); | 35 | let mut args: Vec<String> = env::args().collect(); |
36 | stdin() | 36 | dbg!(&args); |
37 | .read_line(&mut user_input) | 37 | args.reverse(); |
38 | .expect("ERROR"); | 38 | args.pop(); |
39 | args.reverse(); | ||
40 | dbg!(&args); | ||
39 | 41 | ||
40 | let input = Input::from(user_input.trim().to_string())?; | 42 | let input = Input::from(args.join(" "))?; |
41 | 43 | ||
42 | match input.command.as_str() { | 44 | match input.command.as_str() { |
43 | "mod" => { | 45 | "mod" => { |
@@ -49,6 +51,12 @@ pub async fn get_input(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { | |||
49 | "update" => { | 51 | "update" => { |
50 | update(config).await | 52 | update(config).await |
51 | }, | 53 | }, |
54 | "setup" => { | ||
55 | setup(config).await | ||
56 | }, | ||
57 | "download" => { | ||
58 | download(config).await | ||
59 | }, | ||
52 | _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), | 60 | _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), |
53 | } | 61 | } |
54 | } | 62 | } |