Mercurial > cgi-bin > hgweb.cgi > PassMan
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:72619175004e | 10:cbe4c797c9a6 |
---|---|
36 val entry = if (commandLine.hasOption(GENERATE)) { | 36 val entry = if (commandLine.hasOption(GENERATE)) { |
37 val rawLength = commandLine.getOptionValue(LENGTH) | 37 val rawLength = commandLine.getOptionValue(LENGTH) |
38 val length = try { | 38 val length = try { |
39 rawLength?.toInt() ?: DEFAULT_GENERATED_LENGTH | 39 rawLength?.toInt() ?: DEFAULT_GENERATED_LENGTH |
40 } catch (e: NumberFormatException) { | 40 } catch (e: NumberFormatException) { |
41 -1 | |
42 } | |
43 if (length < MIN_GENERATED_LENGTH) { | |
41 die("${see(rawLength)} - invalid length") | 44 die("${see(rawLength)} - invalid length") |
42 -1 /* will never happen */ | |
43 } | 45 } |
44 Entry.withGeneratedPassword(length, | 46 Entry.withGeneratedPassword(length, |
45 commandLine.hasOption(SYMBOLS), | 47 commandLine.hasOption(SYMBOLS), |
46 commandLine.hasOption(VERBOSE)) | 48 commandLine.hasOption(VERBOSE)) |
47 } else { | 49 } else { |