mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-29 07:42:06 +01:00
SOP-CLI: Implement additional version flags
This commit is contained in:
parent
fc432901ed
commit
19b6c8b1e3
2 changed files with 39 additions and 7 deletions
|
@ -6,6 +6,7 @@ package org.pgpainless.sop;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
@ -14,7 +15,7 @@ import sop.operation.Version;
|
|||
public class VersionImpl implements Version {
|
||||
|
||||
// draft version
|
||||
private static final String SOP_VERSION = "3";
|
||||
private static final String SOP_VERSION = "03";
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -42,16 +43,21 @@ public class VersionImpl implements Version {
|
|||
@Override
|
||||
public String getBackendVersion() {
|
||||
double bcVersion = new BouncyCastleProvider().getVersion();
|
||||
return String.format("Bouncy Castle %,.2f", bcVersion);
|
||||
return String.format(Locale.US, "Bouncy Castle %.2f", bcVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtendedVersion() {
|
||||
return getName() + " " + getVersion() + "\n" +
|
||||
"Based on PGPainless " + getVersion() + "\n" +
|
||||
"Using " + getBackendVersion() + "\n" +
|
||||
"See https://pgpainless.org\n" +
|
||||
"https://codeberg.org/PGPainless/pgpainless/src/branch/master/pgpainless-sop\n" +
|
||||
"\n" +
|
||||
"Implementation of the Stateless OpenPGP Protocol Version " + SOP_VERSION + "\n" +
|
||||
"See https://datatracker.ietf.org/doc/html/draft-dkg-openpgp-stateless-cli-03";
|
||||
"https://datatracker.ietf.org/doc/html/draft-dkg-openpgp-stateless-cli-" + SOP_VERSION + "\n" +
|
||||
"\n" +
|
||||
"Based on pgpainless-core " + getVersion() + "\n" +
|
||||
"https://pgpainless.org\n" +
|
||||
"\n" +
|
||||
"Using " + getBackendVersion() + "\n" +
|
||||
"https://www.bouncycastle.org/java.html";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,19 @@ import sop.operation.Version;
|
|||
exitCodeOnInvalidInput = 37)
|
||||
public class VersionCmd implements Runnable {
|
||||
|
||||
@CommandLine.ArgGroup()
|
||||
Exclusive exclusive;
|
||||
|
||||
static class Exclusive {
|
||||
@CommandLine.Option(names = "--extended", description = "Print an extended version string.")
|
||||
boolean extended;
|
||||
|
||||
@CommandLine.Option(names = "--backend", description = "Print information about the cryptographic backend.")
|
||||
boolean backend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Version version = SopCLI.getSop().version();
|
||||
|
@ -21,6 +34,19 @@ public class VersionCmd implements Runnable {
|
|||
throw new SOPGPException.UnsupportedSubcommand("Command 'version' not implemented.");
|
||||
}
|
||||
|
||||
Print.outln(version.getName() + " " + version.getVersion());
|
||||
if (exclusive == null) {
|
||||
Print.outln(version.getName() + " " + version.getVersion());
|
||||
return;
|
||||
}
|
||||
|
||||
if (exclusive.extended) {
|
||||
Print.outln(version.getExtendedVersion());
|
||||
return;
|
||||
}
|
||||
|
||||
if (exclusive.backend) {
|
||||
Print.outln(version.getBackendVersion());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue