From 59056dbdfc70e45f847f9c0254e08d82373ff6ea Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Fri, 20 Sep 2024 13:23:50 +1000 Subject: [PATCH] Cope better when not enough arguments are inputted --- build.gradle.kts | 2 +- src/main/kotlin/Main.kt | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f9b9e4d..69eef7b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ application { } group = "xyz.maxwellj.mapm" -version = "0.0.2" +version = "0.0.3" repositories { mavenCentral() diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 21f4c18..c8e572e 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -54,8 +54,33 @@ fun md5(input:String): String { } suspend fun main(args: Array) { + if (args.size < 2) { + if (args.size == 1) { + if (args[0] == "h") { + println("mapm - Max's Package Manager") + println("Version 0.0.3") + println("(C) Maxwell Jeffress 2024, licensed under the GNU GPL V3") + println("") + println("---Help---") + println("Arguments that can be run") + println("g Grab a package from the internet") + println("r Remove a package") + println("c Generate a checksum for a package") + println("") + println("More info at the following links:") + println("https://maxwellj.xyz/mapm") + println("https://git.maxwellj.xyz/max/mapm") + exitProcess(0) + } else { + println("USAGE: mapm [g, r, c, m] [package name] Type 'h' for help") + exitProcess(1) + } + } else { + println("USAGE: mapm [g, r, c, m] [package name] Type 'h' for help") + exitProcess(1) + } + } var userInput: String = args[0] - println(userInput) if (userInput == "g") { val userInput: String = args[1] val linkToUse = "https://git.maxwellj.xyz/mapm/stable/raw/branch/main/$userInput/source" @@ -99,9 +124,10 @@ suspend fun main(args: Array) { println("Checksum of that file is ${md5(file.readText())}") } else if (userInput == "m") { println("this feature is in progress") - } else { + println("") + } else if (userInput == "h") { println("mapm - Max's Package Manager") - println("Version 0.0.2") + println("Version 0.0.3") println("(C) Maxwell Jeffress 2024, licensed under the GNU GPL V3") println("") println("---Help---")