mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Implement external variants of new subcommands
This commit is contained in:
parent
dd12e28926
commit
69fbfc09a7
5 changed files with 177 additions and 0 deletions
30
external-sop/src/main/kotlin/sop/external/operation/MergeCertsExternal.kt
vendored
Normal file
30
external-sop/src/main/kotlin/sop/external/operation/MergeCertsExternal.kt
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.external.operation
|
||||
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
import sop.Ready
|
||||
import sop.external.ExternalSOP
|
||||
import sop.operation.MergeCerts
|
||||
|
||||
class MergeCertsExternal(binary: String, environment: Properties) : MergeCerts {
|
||||
|
||||
private val commandList = mutableListOf(binary, "version")
|
||||
private val envList = ExternalSOP.propertiesToEnv(environment).toMutableList()
|
||||
|
||||
private var argCount = 0
|
||||
|
||||
override fun noArmor(): MergeCerts = apply { commandList.add("--no-armor") }
|
||||
|
||||
override fun updates(updateCerts: InputStream): MergeCerts = apply {
|
||||
commandList.add("@ENV:CERT_$argCount")
|
||||
envList.add("CERT_$argCount=${ExternalSOP.readString(updateCerts)}")
|
||||
argCount += 1
|
||||
}
|
||||
|
||||
override fun baseCertificates(certs: InputStream): Ready =
|
||||
ExternalSOP.executeTransformingOperation(Runtime.getRuntime(), commandList, envList, certs)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue