From 90373f7b290b142992a624127a011610ba9a5578 Mon Sep 17 00:00:00 2001 From: Jonas_Jones <91549607+J-onasJones@users.noreply.github.com> Date: Mon, 19 Sep 2022 16:37:05 +0200 Subject: [PATCH] added rust files --- Cargo.toml | 17 +++++++++++++++++ src/cliargs/mod.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 22 ++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/cliargs/mod.rs create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c2e1cd5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "moddah" +version = "0.1.0" +authors = ["Jonas_Jones"] +edition = "2021" +description = "A cli tool that allows for easy client and server installation of QuitlMC, FabricMC and ForgeModLoader for Minecraft" +#documentation = "https://doc.jonasjones.me/moddah/" +readme = "README.md" +homepage = "https://jonasjones.me/moddah" +repository = "https://github.com/J-onasJones/moddah" +license = "MIT OR Apache-2.0" +keywords = ["fabric", "quilt", "forge", "mineraft", "modded", "modding"] +categories = ["accessibility", "command-line-utilities", "development-tools"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/cliargs/mod.rs b/src/cliargs/mod.rs new file mode 100644 index 0000000..cb74f8f --- /dev/null +++ b/src/cliargs/mod.rs @@ -0,0 +1,43 @@ +pub(crate) fn help() +{{ + println!("Moddah is a managing tool for Minecraft modded clients and servers. +The supported toolchains are FabricMC, ForgeModLoader, QuiltMC. + +Usage: + moddah + moddah [...] + +Operations: + moddah {{-h --help}} print this help message + moddah {{-v --version}} print the version of Moddah + moddah {{-l --list}} [...] list versions + moddah {{-i --install}} [...] install a Modloader + +Options: + moddah {{-l --list}} [...] + - minecraft list all minecraft versions + - fabric list all minecraft versions supported by the FabricMC toolchain + - forge list all minecraft versions supported by the ForgeModLoader toolchain + - quilt list all minecraft versions supported by the QuiltMC toolchain + + moddah {{-i --install}} [modloader] [minecraft-version] [environment] [loader-version] [directory] + [modloader]: + - fabric + - forge + - quilt + + [minecraft-version]: + - [any version that is supported by the modloader of choice] + + [environment]: + - client + - server + + [loader-version]: + - [any version of the loader of choice] + + [directory]: + - [leave blank for current directory] + - [directory of choice] + ") +}} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..312bd2b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,22 @@ +use std::env; + +mod cliargs; + +fn main() { + let args: Vec = env::args().collect(); + for i in args.iter() + { + match i.as_str() + { + "--help" => cliargs::help(), + _ => { + if !args.iter().position(|r| r.as_str() == i).unwrap().parse() == 0 + { + println!("Error") + } else { + println!("{}", args.iter().position(|r| r.as_str() == i).unwrap()); + } + }, + } + } +} \ No newline at end of file