view src/main/kotlin/name/blackcap/passman/HelpSubcommand.kt @ 28:287eadf5ab30 default tip

Check for timeouts inside subcommands while in interactive mode as well.
author David Barts <n5jrn@me.com>
date Wed, 31 Jul 2024 11:21:18 -0700
parents 2188b2f13326
children
line wrap: on
line source

package name.blackcap.passman

class HelpSubcommand(): Subcommand() {
    override fun run(args: Array<String>) {
        if (args.isEmpty() || args[0] == "-h" || args[0].startsWith("--h")) {
            listSubcommands()
        } else {
            helpForSubcommand(args[0])
        }
    }

    private fun listSubcommands() {
        println("PassMan: a password manager")
        println("Available subcommands:")
        println("create       Create a new username/password pair.")
        println("delete       Delete existing record.")
        println("help         Print this message.")
        println("export       Export to CSV file.")
        println("import       Import from CSV file.")
        println("list         List records.")
        println("merge        Merge passwords in from another PassMan database.")
        println("password     Change database encryption key.")
        println("quit         Exit from interactive mode.")
        println("read         Retrieve data from existing record.")
        println("rename       Rename existing record.")
        println("update       Update existing record.")
        println()
        println("Database is ${see(DB_FILE)} .")
    }

    private fun helpForSubcommand(subcom: String) {
        runSubcommand(subcom, arrayOf<String>("--help"))
    }
}