summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorfx <[email protected]>2023-04-23 14:13:03 +0200
committerfx <[email protected]>2023-04-23 14:13:03 +0200
commit4300ad2eb05dddfa4274e04b204f2ad28c87da05 (patch)
treea2fd059e3aefff812d0d25e23fc85203dc9d122a /src/lib.rs
parent2711f05669e353fbf452156d54855e9ba454f4a8 (diff)
parent64958cc9ff0858dbf068625e35b8d5dae249d4a4 (diff)
downloadmodlist-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.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index eb845d8..43f0fe7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,36 +1,37 @@
1pub mod apis; 1pub mod apis;
2pub mod config;
3pub mod commands; 2pub mod commands;
4pub mod input; 3pub mod config;
5pub mod db; 4pub mod db;
6pub mod error; 5pub mod error;
7pub mod files; 6pub mod files;
8 7
9use std::path::Path; 8use std::{fmt::Display, path::Path};
10 9
11pub use apis::*; 10pub use apis::*;
12pub use commands::*; 11pub use commands::*;
13use error::{MLE, ErrorType, MLError}; 12use error::{ErrorType, MLError, MLE};
14 13
15#[derive(Debug, Clone, PartialEq, Eq)] 14#[derive(Debug, Clone, PartialEq, Eq)]
16pub enum Modloader { 15pub enum Modloader {
17 Fabric, 16 Fabric,
18 Forge 17 Forge,
19} 18}
20 19
21impl Modloader { 20impl 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
30impl 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}