Mercurial > cgi-bin > hgweb.cgi > PassMan
view src/main/kotlin/name/blackcap/passman/DeleteSubcommand.kt @ 5:ad997df1f560
Fix see() to be about as good as sccc.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 11 Sep 2022 21:29:20 -0700 |
parents | eafa3779aef8 |
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)}") } } } }