Mercurial > cgi-bin > hgweb.cgi > PassMan
view src/main/kotlin/name/blackcap/passman/DeleteSubcommand.kt @ 7:f245b9a53495
Efficiency improvements.
author | David Barts <n5jrn@me.com> |
---|---|
date | Tue, 20 Sep 2022 21:54:32 -0700 |
parents | 711cc42e96d7 |
children | 698c4a3d758d |
line wrap: on
line source
package name.blackcap.passman import kotlin.system.exitProcess class DeleteSubcommand(): Subcommand() { override fun run(args: Array<String>) { if (args.isEmpty()) { die("expecting a site name", 2) } val db = Database.open() var errors = 0 for (nameIn in args) { db.connection.prepareStatement("delete from passwords where id = ?").use { it.setLong(1, db.makeKey(nameIn)) if (it.executeUpdate() == 0) { error("no record matches ${see(nameIn)}") errors++ } } } exitProcess(if (errors > 0) 1 else 0) } }