comparison src/main/kotlin/name/blackcap/passman/CreateSubcommand.kt @ 6:711cc42e96d7

Got the list subcommand working, but needs efficiency improvements.
author David Barts <n5jrn@me.com>
date Tue, 20 Sep 2022 20:52:21 -0700
parents eafa3779aef8
children 698c4a3d758d
comparison
equal deleted inserted replaced
5:ad997df1f560 6:711cc42e96d7
1 package name.blackcap.passman 1 package name.blackcap.passman
2 2
3 import org.apache.commons.cli.CommandLine 3 import org.apache.commons.cli.*
4 import org.apache.commons.cli.DefaultParser
5 import org.apache.commons.cli.Options
6 import org.apache.commons.cli.ParseException
7 import kotlin.system.exitProcess 4 import kotlin.system.exitProcess
8 5
9 class CreateSubcommand(): Subcommand() { 6 class CreateSubcommand(): Subcommand() {
10 private lateinit var commandLine: CommandLine 7 private lateinit var commandLine: CommandLine
11 8
18 } 15 }
19 try { 16 try {
20 commandLine = DefaultParser().parse(options, args) 17 commandLine = DefaultParser().parse(options, args)
21 } catch (e: ParseException) { 18 } catch (e: ParseException) {
22 die(e.message ?: "syntax error", 2) 19 die(e.message ?: "syntax error", 2)
20 }
21 if (commandLine.hasOption("help")) {
22 HelpFormatter().printHelp("$SHORTNAME createJv", options)
23 exitProcess(0)
23 } 24 }
24 checkArguments() 25 checkArguments()
25 val db = Database.open() 26 val db = Database.open()
26 27
27 val entry = if (commandLine.hasOption("generate")) { 28 val entry = if (commandLine.hasOption("generate")) {