Mercurial > cgi-bin > hgweb.cgi > PassMan
view 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 |
line wrap: on
line source
package name.blackcap.passman class DeleteSubcommand(): Subcommand() { override fun run(args: Array<String>) { if (args.isEmpty()) { die("expecting a site name", 2) } if (args.size > 1) { die("unexpected trailing arguments", 2) } val nameIn = args[0] val db = Database.open() db.connection.prepareStatement("delete from passwords where id = ?").use { it.setLong(1, db.makeKey(nameIn)) if (it.executeUpdate() == 0) { die("no record matches ${see(nameIn)}") } } } }