summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-04-17 20:30:16 +0200
committerfxqnlr <[email protected]>2023-04-17 20:30:16 +0200
commit93e61a4bd6ad8b5db1083bdd21994bf73b0b90ba (patch)
tree043adeff1c117f3f0e4fe7bffc472c299e01d642 /src/lib.rs
parent77d2ac94534b12300b5b7eff6e28023d815708eb (diff)
downloadmodlist-93e61a4bd6ad8b5db1083bdd21994bf73b0b90ba.tar
modlist-93e61a4bd6ad8b5db1083bdd21994bf73b0b90ba.tar.gz
modlist-93e61a4bd6ad8b5db1083bdd21994bf73b0b90ba.zip
added clap cli, modified (basically) all user interface functions;
changed some functions to easier string handling
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/lib.rs b/src/lib.rs
index eb845d8..8d97d1a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,7 @@ pub mod db;
6pub mod error; 6pub mod error;
7pub mod files; 7pub mod files;
8 8
9use std::path::Path; 9use std::{path::Path, fmt::Display};
10 10
11pub use apis::*; 11pub use apis::*;
12pub use commands::*; 12pub use commands::*;
@@ -19,14 +19,7 @@ pub enum Modloader {
19} 19}
20 20
21impl Modloader { 21impl Modloader {
22 fn to_string(&self) -> String { 22 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 { 23 match string {
31 "forge" => Ok(Modloader::Forge), 24 "forge" => Ok(Modloader::Forge),
32 "fabric" => Ok(Modloader::Fabric), 25 "fabric" => Ok(Modloader::Fabric),
@@ -35,6 +28,15 @@ impl Modloader {
35 } 28 }
36} 29}
37 30
31impl Display for Modloader {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 match self {
34 Modloader::Fabric => write!(f, "fabric"),
35 Modloader::Forge => write!(f, "forge"),
36 }
37 }
38}
39
38pub fn devdir(path: &str) -> String { 40pub fn devdir(path: &str) -> String {
39 let p = Path::new(path); 41 let p = Path::new(path);
40 let dev = std::env::var("DEV"); 42 let dev = std::env::var("DEV");