diff options
author | fxqnlr <[email protected]> | 2022-11-04 23:41:21 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-04 23:41:21 +0100 |
commit | 5d50f446a1a4612c0c931bdbc61f945760392f29 (patch) | |
tree | 44414994e19b41979a8a939b120ada0d1aa8a13a /src/input.rs | |
parent | 96cc5257de09682df345e768dc2a91303f9b36c9 (diff) | |
download | modlist-5d50f446a1a4612c0c931bdbc61f945760392f29.tar modlist-5d50f446a1a4612c0c931bdbc61f945760392f29.tar.gz modlist-5d50f446a1a4612c0c931bdbc61f945760392f29.zip |
"finished" update, added some tests
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/input.rs b/src/input.rs index 0c13e67..e0c9ae9 100644 --- a/src/input.rs +++ b/src/input.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | use std::io::{stdin, Error, ErrorKind}; | 1 | use std::io::{stdin, Error, ErrorKind}; |
2 | use crate::{config::Cfg, list, modification, update}; | 2 | use crate::{config::Cfg, list, modification, update}; |
3 | 3 | ||
4 | #[derive(Debug, PartialEq, Eq)] | ||
4 | pub struct Input { | 5 | pub struct Input { |
5 | pub command: String, | 6 | pub command: String, |
6 | pub args: Option<Vec<String>>, | 7 | pub args: Option<Vec<String>>, |
@@ -27,8 +28,6 @@ impl Input { | |||
27 | }, | 28 | }, |
28 | _ => { panic!("This should never happen") } | 29 | _ => { panic!("This should never happen") } |
29 | } | 30 | } |
30 | |||
31 | |||
32 | } | 31 | } |
33 | } | 32 | } |
34 | 33 | ||
@@ -53,3 +52,10 @@ pub async fn get_input(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { | |||
53 | _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), | 52 | _ => Err(Box::new(Error::new(ErrorKind::InvalidInput, "UNKNOWN_COMMAND"))), |
54 | } | 53 | } |
55 | } | 54 | } |
55 | |||
56 | #[test] | ||
57 | fn input_from() { | ||
58 | let string = String::from("list add test 1.19.2 fabric"); | ||
59 | let input = Input { command: String::from("list"), args: Some(vec![String::from("add"), String::from("test"), String::from("1.19.2"), String::from("fabric")]) }; | ||
60 | assert_eq!(Input::from(string).unwrap(), input); | ||
61 | } | ||