Mercurial > cgi-bin > hgweb.cgi > PassMan
diff src/main/kotlin/name/blackcap/passman/Arguments.kt @ 21:ea65ab890f66
More work to support interactive feature.
author | David Barts <n5jrn@me.com> |
---|---|
date | Tue, 02 Jul 2024 11:27:39 -0700 |
parents | 7a74ae668665 |
children | 3a3067ba673b |
line wrap: on
line diff
--- a/src/main/kotlin/name/blackcap/passman/Arguments.kt Sun Jun 30 22:28:52 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/Arguments.kt Tue Jul 02 11:27:39 2024 -0700 @@ -59,12 +59,11 @@ commandLine = try { DefaultParser().parse(options, args) } catch (e: ParseException) { - die(e.message ?: "syntax error", 2) - throw RuntimeException("this will never happen") + throw SubcommandException(message = e.message ?: "syntax error", status = 2) } if (commandLine.hasOption("help")) { HelpFormatter().printHelp("$SHORTNAME $name [options] csv_file", options) - exitProcess(0) + throw SubcommandException(status = 0) } } @@ -92,11 +91,10 @@ private fun CommandLine.getCharOptionValue(name: String): Char { val optionValue = getOptionValue(name) when (optionValue.length) { - 0 -> die("--$name value must not be empty") + 0 -> throw SubcommandException(message = "--$name value must not be empty") 1 -> return optionValue[0] - else -> die("--$name value must be a single character") + else -> throw SubcommandException(message = "--$name value must be a single character") } - throw RuntimeException("this will never happen") } }