diff src/main/kotlin/name/blackcap/passman/UpdateSubcommand.kt @ 6:711cc42e96d7

Got the list subcommand working, but needs efficiency improvements.
author David Barts <n5jrn@me.com>
date Tue, 20 Sep 2022 20:52:21 -0700
parents eafa3779aef8
children 698c4a3d758d
line wrap: on
line diff
--- a/src/main/kotlin/name/blackcap/passman/UpdateSubcommand.kt	Sun Sep 11 21:29:20 2022 -0700
+++ b/src/main/kotlin/name/blackcap/passman/UpdateSubcommand.kt	Tue Sep 20 20:52:21 2022 -0700
@@ -1,9 +1,6 @@
 package name.blackcap.passman
 
-import org.apache.commons.cli.CommandLine
-import org.apache.commons.cli.DefaultParser
-import org.apache.commons.cli.Options
-import org.apache.commons.cli.ParseException
+import org.apache.commons.cli.*
 import java.sql.Types
 import java.util.*
 import kotlin.properties.Delegates
@@ -36,6 +33,7 @@
     private fun parseArguments(args: Array<String>) {
         val options = Options().apply {
             addOption("g", "generate", false, "Use password generator.")
+            addOption("h", "help", false, "Print this help message.")
             addOption("l", "length", true, "Length of generated password.")
             addOption("s", "symbols", false, "Use symbol characters in generated password.")
             addOption("v", "verbose", false, "Print the generated password.")
@@ -45,6 +43,10 @@
         } catch (e: ParseException) {
             die(e.message ?: "syntax error", 2)
         }
+        if (commandLine.hasOption("help")) {
+            HelpFormatter().printHelp("$SHORTNAME update", options)
+            exitProcess(0)
+        }
         checkArguments()
         db = Database.open()
         nameIn = commandLine.args[0]