From 93e61a4bd6ad8b5db1083bdd21994bf73b0b90ba Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 17 Apr 2023 20:30:16 +0200 Subject: added clap cli, modified (basically) all user interface functions; changed some functions to easier string handling --- src/lib.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/lib.rs') 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; pub mod error; pub mod files; -use std::path::Path; +use std::{path::Path, fmt::Display}; pub use apis::*; pub use commands::*; @@ -19,14 +19,7 @@ pub enum Modloader { } impl Modloader { - fn to_string(&self) -> String { - match self { - Modloader::Fabric => String::from("fabric"), - Modloader::Forge => String::from("forge"), - } - } - - fn from(string: &str) -> MLE { + pub fn from(string: &str) -> MLE { match string { "forge" => Ok(Modloader::Forge), "fabric" => Ok(Modloader::Fabric), @@ -35,6 +28,15 @@ impl Modloader { } } +impl Display for Modloader { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Modloader::Fabric => write!(f, "fabric"), + Modloader::Forge => write!(f, "forge"), + } + } +} + pub fn devdir(path: &str) -> String { let p = Path::new(path); let dev = std::env::var("DEV"); -- cgit v1.2.3