Mercurial > cgi-bin > hgweb.cgi > PassMan
diff src/main/kotlin/name/blackcap/passman/ExportSubcommand.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 | 07406c4af4a5 |
line wrap: on
line diff
--- a/src/main/kotlin/name/blackcap/passman/ExportSubcommand.kt Sun Jun 30 22:28:52 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/ExportSubcommand.kt Tue Jul 02 11:27:39 2024 -0700 @@ -18,22 +18,22 @@ private val options = ImportExportArguments() private lateinit var csvFile: String - override fun run(args: Array<String>) { + override fun run(args: Array<String>): { parseArguments(args) - db = Database.open() + db = Database.default try { doExport() } catch (e: IOException) { - die(e.message ?: "I/O error") + throw SubcommandException(message = e.message ?: "I/O error", cause = e) } } private fun parseArguments(args: Array<String>) { val params = parseInto("export", args, options) when (params.size) { - 0 -> die("expecting CSV file name", 2) + 0 -> throw SubcommandException(message = "expecting CSV file name", status = 2) 1 -> csvFile = params[0] - else -> die("unexpected trailing arguments", 2) + else -> throw SubcommandException(message = "unexpected trailing arguments", status = 2) } csvDateFormat = SimpleDateFormat(options.format).apply { timeZone = TimeZone.getTimeZone(options.zone) @@ -74,4 +74,4 @@ val value = getDate(columnIndex) return if (value == null) NULL else csvDateFormat.format(value) } -} \ No newline at end of file +}