mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-10 02:39:45 +02:00
Add implementation of merge-certs command
This commit is contained in:
parent
bd692c7309
commit
a98afb1755
6 changed files with 116 additions and 0 deletions
|
@ -0,0 +1,48 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.cli.picocli.commands
|
||||
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.Command
|
||||
import sop.cli.picocli.SopCLI
|
||||
import sop.exception.SOPGPException
|
||||
import java.io.IOException
|
||||
|
||||
@Command(
|
||||
name = "merge-certs",
|
||||
resourceBundle = "msg_merge-certs",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
class MergeCertsCmd : AbstractSopCmd() {
|
||||
|
||||
@CommandLine.Option(names = ["--no-armor"], negatable = true)
|
||||
var armor = false
|
||||
|
||||
@CommandLine.Parameters(paramLabel = "CERTS")
|
||||
var updates: List<String> = listOf()
|
||||
|
||||
override fun run() {
|
||||
val mergeCerts = throwIfUnsupportedSubcommand(SopCLI.getSop().mergeCerts(), "merge-certs")
|
||||
|
||||
if (!armor) {
|
||||
mergeCerts.noArmor()
|
||||
}
|
||||
|
||||
for (certFileName in updates) {
|
||||
try {
|
||||
getInput(certFileName).use { mergeCerts.updates(it) }
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
val ready = mergeCerts.baseCertificates(System.`in`)
|
||||
ready.writeTo(System.out)
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue