comparison src/main/kotlin/name/blackcap/passman/HelpSubcommand.kt @ 24:2188b2f13326

Make some minor tweaks to the help system.
author David Barts <n5jrn@me.com>
date Wed, 03 Jul 2024 17:14:22 -0700
parents 07406c4af4a5
children
comparison
equal deleted inserted replaced
23:af86b8e0b88c 24:2188b2f13326
1 package name.blackcap.passman 1 package name.blackcap.passman
2 2
3 class HelpSubcommand(): Subcommand() { 3 class HelpSubcommand(): Subcommand() {
4 override fun run(args: Array<String>) { 4 override fun run(args: Array<String>) {
5 if (args.isEmpty() || args[0] == "-h" || args[0].startsWith("--h")) {
6 listSubcommands()
7 } else {
8 helpForSubcommand(args[0])
9 }
10 }
11
12 private fun listSubcommands() {
5 println("PassMan: a password manager") 13 println("PassMan: a password manager")
6 println("Available subcommands:") 14 println("Available subcommands:")
7 println("create Create a new username/password pair.") 15 println("create Create a new username/password pair.")
8 println("delete Delete existing record.") 16 println("delete Delete existing record.")
9 println("help Print this message.") 17 println("help Print this message.")
17 println("rename Rename existing record.") 25 println("rename Rename existing record.")
18 println("update Update existing record.") 26 println("update Update existing record.")
19 println() 27 println()
20 println("Database is ${see(DB_FILE)} .") 28 println("Database is ${see(DB_FILE)} .")
21 } 29 }
30
31 private fun helpForSubcommand(subcom: String) {
32 runSubcommand(subcom, arrayOf<String>("--help"))
33 }
22 } 34 }