diff options
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/input.rs b/src/input.rs index 0b616d4..0946971 100644 --- a/src/input.rs +++ b/src/input.rs | |||
@@ -7,18 +7,16 @@ pub struct Input { | |||
7 | pub subcommand: Option<Subcmd>, | 7 | pub subcommand: Option<Subcmd>, |
8 | pub args: Option<Vec<String>>, | 8 | pub args: Option<Vec<String>>, |
9 | pub direct_download: bool, | 9 | pub direct_download: bool, |
10 | pub force_download: bool, | ||
11 | pub all_lists: bool, | 10 | pub all_lists: bool, |
12 | pub delete_old: bool, | 11 | pub delete_old: bool, |
13 | pub clean: bool, | 12 | pub clean: bool, |
14 | } | 13 | } |
15 | 14 | ||
16 | impl Input { | 15 | impl Input { |
17 | pub fn from(string: &str) -> MLE<Self> { | 16 | fn from(string: &str) -> MLE<Self> { |
18 | let mut split: Vec<&str> = string.split(' ').collect(); | 17 | let mut split: Vec<&str> = string.split(' ').collect(); |
19 | 18 | ||
20 | let mut direct_download = false; | 19 | let mut direct_download = false; |
21 | let mut force_download = false; | ||
22 | let mut all_lists = false; | 20 | let mut all_lists = false; |
23 | let mut delete_old = false; | 21 | let mut delete_old = false; |
24 | let mut clean = false; | 22 | let mut clean = false; |
@@ -27,9 +25,8 @@ impl Input { | |||
27 | if input.starts_with("--") { | 25 | if input.starts_with("--") { |
28 | match input { | 26 | match input { |
29 | "--direct-download" => direct_download = true, | 27 | "--direct-download" => direct_download = true, |
30 | "--force-download" => force_download = true, | 28 | "--all-lists" => all_lists = true, |
31 | "--all_lists" => all_lists = true, | 29 | "--delete-old" => delete_old = true, |
32 | "--delete_old" => delete_old = true, | ||
33 | "--clean" => clean = true, | 30 | "--clean" => clean = true, |
34 | _ => continue, | 31 | _ => continue, |
35 | } | 32 | } |
@@ -54,7 +51,7 @@ impl Input { | |||
54 | } | 51 | } |
55 | }; | 52 | }; |
56 | 53 | ||
57 | Ok(Self { command, subcommand, args, direct_download, force_download, all_lists, delete_old, clean }) | 54 | Ok(Self { command, subcommand, args, direct_download, all_lists, delete_old, clean }) |
58 | } | 55 | } |
59 | } | 56 | } |
60 | 57 | ||
@@ -68,7 +65,7 @@ pub enum Cmd { | |||
68 | } | 65 | } |
69 | 66 | ||
70 | impl Cmd { | 67 | impl Cmd { |
71 | pub fn from(string: &str) -> MLE<Self> { | 68 | fn from(string: &str) -> MLE<Self> { |
72 | let cmd = match string { | 69 | let cmd = match string { |
73 | "mod" => Self::Mod, | 70 | "mod" => Self::Mod, |
74 | "list" => Self::List, | 71 | "list" => Self::List, |
@@ -130,6 +127,6 @@ pub async fn get_input(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { | |||
130 | #[test] | 127 | #[test] |
131 | fn input_from() { | 128 | fn input_from() { |
132 | let string = "list add test 1.19.2 fabric"; | 129 | let string = "list add test 1.19.2 fabric"; |
133 | let input = Input{ command: Cmd::List, subcommand: Some(Subcmd::Add), args: Some(vec![String::from("test"), String::from("1.19.2"), String::from("fabric")]), force_download: false, direct_download: false, all_lists: false, clean: false, delete_old: false }; | 130 | let input = Input{ command: Cmd::List, subcommand: Some(Subcmd::Add), args: Some(vec![String::from("test"), String::from("1.19.2"), String::from("fabric")]), direct_download: false, all_lists: false, clean: false, delete_old: false }; |
134 | assert_eq!(Input::from(string).unwrap(), input); | 131 | assert_eq!(Input::from(string).unwrap(), input); |
135 | } | 132 | } |