revoke-key command: Allow for multiple '--with-key-password' options

This commit is contained in:
Paul Schaub 2024-09-19 20:13:12 +02:00
parent 42a16a4f6d
commit 375dd65789
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -19,8 +19,8 @@ class RevokeKeyCmd : AbstractSopCmd() {
@Option(names = ["--no-armor"], negatable = true) var armor = true @Option(names = ["--no-armor"], negatable = true) var armor = true
@Option(names = ["--with-key-password"], paramLabel = "PASSWORD") @Option(names = ["--with-key-password"], paramLabel = "PASSWORD", arity = "0..*")
var withKeyPassword: String? = null var withKeyPassword: List<String> = listOf()
override fun run() { override fun run() {
val revokeKey = throwIfUnsupportedSubcommand(SopCLI.getSop().revokeKey(), "revoke-key") val revokeKey = throwIfUnsupportedSubcommand(SopCLI.getSop().revokeKey(), "revoke-key")
@ -29,9 +29,9 @@ class RevokeKeyCmd : AbstractSopCmd() {
revokeKey.noArmor() revokeKey.noArmor()
} }
withKeyPassword?.let { for (passwordIn in withKeyPassword) {
try { try {
val password = stringFromInputStream(getInput(it)) val password = stringFromInputStream(getInput(passwordIn))
revokeKey.withKeyPassword(password) revokeKey.withKeyPassword(password)
} catch (e: SOPGPException.UnsupportedOption) { } catch (e: SOPGPException.UnsupportedOption) {
val errorMsg = val errorMsg =