Mercurial > cgi-bin > hgweb.cgi > PassMan
comparison src/main/kotlin/name/blackcap/passman/UpdateSubcommand.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 |
comparison
equal
deleted
inserted
replaced
9:72619175004e | 10:cbe4c797c9a6 |
---|---|
55 } | 55 } |
56 checkArguments() | 56 checkArguments() |
57 db = Database.open() | 57 db = Database.open() |
58 nameIn = commandLine.args[0] | 58 nameIn = commandLine.args[0] |
59 id = db.makeKey(nameIn) | 59 id = db.makeKey(nameIn) |
60 length = commandLine.getOptionValue(LENGTH)?.let { rawLength -> | 60 val rawLength = commandLine.getOptionValue(LENGTH) |
61 try { | 61 length = try { |
62 rawLength.toInt() | 62 rawLength?.toInt() ?: DEFAULT_GENERATED_LENGTH |
63 } catch (e: NumberFormatException) { | 63 } catch (e: NumberFormatException) { |
64 die("${see(rawLength)} - invalid length") | 64 -1 |
65 -1 /* will never happen */ | 65 } |
66 } | 66 if (length < MIN_GENERATED_LENGTH) { |
67 } ?: DEFAULT_GENERATED_LENGTH | 67 die("${see(rawLength)} - invalid length") |
68 } | |
68 } | 69 } |
69 | 70 |
70 private fun checkArguments(): Unit { | 71 private fun checkArguments(): Unit { |
71 var bad = false | 72 var bad = false |
72 if (!commandLine.hasOption(GENERATE)) { | 73 if (!commandLine.hasOption(GENERATE)) { |