diff options
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 | } | ||