diff options
author | fx <[email protected]> | 2023-04-23 14:13:03 +0200 |
---|---|---|
committer | fx <[email protected]> | 2023-04-23 14:13:03 +0200 |
commit | 4300ad2eb05dddfa4274e04b204f2ad28c87da05 (patch) | |
tree | a2fd059e3aefff812d0d25e23fc85203dc9d122a /src/lib.rs | |
parent | 2711f05669e353fbf452156d54855e9ba454f4a8 (diff) | |
parent | 64958cc9ff0858dbf068625e35b8d5dae249d4a4 (diff) | |
download | modlist-4300ad2eb05dddfa4274e04b204f2ad28c87da05.tar modlist-4300ad2eb05dddfa4274e04b204f2ad28c87da05.tar.gz modlist-4300ad2eb05dddfa4274e04b204f2ad28c87da05.zip |
Merge pull request 'clap' (#1) from clap into master
Reviewed-on: http://raspberrypi.fritz.box:7920/fx/modlist/pulls/1
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -1,36 +1,37 @@ | |||
1 | pub mod apis; | 1 | pub mod apis; |
2 | pub mod config; | ||
3 | pub mod commands; | 2 | pub mod commands; |
4 | pub mod input; | 3 | pub mod config; |
5 | pub mod db; | 4 | pub mod db; |
6 | pub mod error; | 5 | pub mod error; |
7 | pub mod files; | 6 | pub mod files; |
8 | 7 | ||
9 | use std::path::Path; | 8 | use std::{fmt::Display, path::Path}; |
10 | 9 | ||
11 | pub use apis::*; | 10 | pub use apis::*; |
12 | pub use commands::*; | 11 | pub use commands::*; |
13 | use error::{MLE, ErrorType, MLError}; | 12 | use error::{ErrorType, MLError, MLE}; |
14 | 13 | ||
15 | #[derive(Debug, Clone, PartialEq, Eq)] | 14 | #[derive(Debug, Clone, PartialEq, Eq)] |
16 | pub enum Modloader { | 15 | pub enum Modloader { |
17 | Fabric, | 16 | Fabric, |
18 | Forge | 17 | Forge, |
19 | } | 18 | } |
20 | 19 | ||
21 | impl Modloader { | 20 | impl Modloader { |
22 | fn to_string(&self) -> String { | 21 | pub fn from(string: &str) -> MLE<Modloader> { |
23 | match self { | ||
24 | Modloader::Fabric => String::from("fabric"), | ||
25 | Modloader::Forge => String::from("forge"), | ||
26 | } | ||
27 | } | ||
28 | |||
29 | fn from(string: &str) -> MLE<Modloader> { | ||
30 | match string { | 22 | match string { |
31 | "forge" => Ok(Modloader::Forge), | 23 | "forge" => Ok(Modloader::Forge), |
32 | "fabric" => Ok(Modloader::Fabric), | 24 | "fabric" => Ok(Modloader::Fabric), |
33 | _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")) | 25 | _ => Err(MLError::new(ErrorType::ArgumentError, "UNKNOWN_MODLOADER")), |
26 | } | ||
27 | } | ||
28 | } | ||
29 | |||
30 | impl Display for Modloader { | ||
31 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
32 | match self { | ||
33 | Modloader::Fabric => write!(f, "fabric"), | ||
34 | Modloader::Forge => write!(f, "forge"), | ||
34 | } | 35 | } |
35 | } | 36 | } |
36 | } | 37 | } |