1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 03:17:58 +01:00

version --extended: Include sop-java version

Fixes #454
This commit is contained in:
Paul Schaub 2024-12-21 13:41:37 +01:00
parent 5018386318
commit 4dbc633d7d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -8,6 +8,7 @@ import java.io.IOException
import java.io.InputStream import java.io.InputStream
import java.util.* import java.util.*
import org.bouncycastle.jce.provider.BouncyCastleProvider import org.bouncycastle.jce.provider.BouncyCastleProvider
import sop.SOP
import sop.operation.Version import sop.operation.Version
/** Implementation of the `version` operation using PGPainless. */ /** Implementation of the `version` operation using PGPainless. */
@ -32,7 +33,7 @@ https://datatracker.ietf.org/doc/html/draft-dkg-openpgp-stateless-cli-$specVersi
Based on pgpainless-core ${getVersion()} Based on pgpainless-core ${getVersion()}
https://pgpainless.org https://pgpainless.org
${formatSopJavaVersion()}
Using $bcVersion Using $bcVersion
https://www.bouncycastle.org/java.html""" https://www.bouncycastle.org/java.html"""
} }
@ -49,8 +50,8 @@ https://www.bouncycastle.org/java.html"""
// See https://stackoverflow.com/a/50119235 // See https://stackoverflow.com/a/50119235
return try { return try {
val resourceIn: InputStream = val resourceIn: InputStream =
javaClass.getResourceAsStream("/pgpainless-sop.properties") SOP::class.java.getResourceAsStream("/pgpainless-sop.properties")
?: throw IOException("File version.properties not found.") ?: throw IOException("File pgpainless-sop.properties not found.")
val properties = Properties().apply { load(resourceIn) } val properties = Properties().apply { load(resourceIn) }
properties.getProperty("pgpainless-sop-version") properties.getProperty("pgpainless-sop-version")
@ -59,5 +60,29 @@ https://www.bouncycastle.org/java.html"""
} }
} }
private fun formatSopJavaVersion(): String {
return getSopJavaVersion()?.let {
"""
sop-java $it
"""
.trimIndent()
}
?: ""
}
private fun getSopJavaVersion(): String? {
return try {
val resourceIn: InputStream =
javaClass.getResourceAsStream("/sop-java-version.properties")
?: throw IOException("File sop-java-version.properties not found.")
val properties = Properties().apply { load(resourceIn) }
properties.getProperty("sop-java-version")
} catch (e: IOException) {
null
}
}
override fun isSopSpecImplementationIncomplete(): Boolean = false override fun isSopSpecImplementationIncomplete(): Boolean = false
} }