diff src/main/kotlin/name/blackcap/passman/CreateSubcommand.kt @ 10:cbe4c797c9a6

Fix bug in parsing --length
author David Barts <n5jrn@me.com>
date Sat, 01 Oct 2022 20:43:59 -0700
parents 72619175004e
children 302d224bbd57
line wrap: on
line diff
--- a/src/main/kotlin/name/blackcap/passman/CreateSubcommand.kt	Sat Oct 01 09:57:23 2022 -0700
+++ b/src/main/kotlin/name/blackcap/passman/CreateSubcommand.kt	Sat Oct 01 20:43:59 2022 -0700
@@ -38,8 +38,10 @@
             val length = try {
                 rawLength?.toInt() ?: DEFAULT_GENERATED_LENGTH
             } catch (e: NumberFormatException) {
+                -1
+            }
+            if (length < MIN_GENERATED_LENGTH) {
                 die("${see(rawLength)} - invalid length")
-                -1  /* will never happen */
             }
             Entry.withGeneratedPassword(length,
                 commandLine.hasOption(SYMBOLS),