comparison src/main/kotlin/name/blackcap/passman/DeleteSubcommand.kt @ 22:07406c4af4a5

More interactive mode stuff.
author David Barts <n5jrn@me.com>
date Tue, 02 Jul 2024 17:34:52 -0700
parents ea65ab890f66
children
comparison
equal deleted inserted replaced
21:ea65ab890f66 22:07406c4af4a5
1 package name.blackcap.passman 1 package name.blackcap.passman
2 2
3 class DeleteSubcommand(): Subcommand() { 3 class DeleteSubcommand(): Subcommand() {
4 override fun run(args: Array<String>): { 4 override fun run(args: Array<String>) {
5 if (args.isEmpty()) { 5 if (args.isEmpty()) {
6 throw SubcommandException(message = "expecting a site name", status = 2) 6 throw SubcommandException(message = "expecting a site name", status = 2)
7 } 7 }
8 if (args[0] == "-h" || args[0].startsWith("--h")) { 8 if (args[0] == "-h" || args[0].startsWith("--h")) {
9 println("usage: passman delete name [...]") 9 println("usage: passman delete name [...]")
10 return 0 10 return
11 } 11 }
12 val db = Database.default 12 val db = Database.default
13 var errors = 0 13 var errors = 0
14 for (nameIn in args) { 14 for (nameIn in args) {
15 db.connection.prepareStatement("delete from passwords where id = ?").use { 15 db.connection.prepareStatement("delete from passwords where id = ?").use {