comparison src/main/kotlin/name/blackcap/passman/DeleteSubcommand.kt @ 3:eafa3779aef8

More bug fixes, quote strings in diagnostics.
author David Barts <n5jrn@me.com>
date Sun, 11 Sep 2022 20:36:06 -0700
parents a6cfdffcaa94
children 711cc42e96d7
comparison
equal deleted inserted replaced
2:3c792ad36b3d 3:eafa3779aef8
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 println("Not yet implemented") 5 if (args.isEmpty()) {
6 die("expecting a site name", 2)
7 }
8 if (args.size > 1) {
9 die("unexpected trailing arguments", 2)
10 }
11 val nameIn = args[0]
12 val db = Database.open()
13 db.connection.prepareStatement("delete from passwords where id = ?").use {
14 it.setLong(1, db.makeKey(nameIn))
15 if (it.executeUpdate() == 0) {
16 die("no record matches ${see(nameIn)}")
17 }
18 }
6 } 19 }
7 } 20 }