Add WIP status command

This commit is contained in:
Paul Schaub 2025-09-04 13:16:57 +02:00
parent e0952aaf60
commit 4c58775f17
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 119 additions and 13 deletions

View file

@ -0,0 +1,58 @@
package org.pgpainless;
import org.pgpainless.bouncycastle.sop.BouncyCastleSOP;
import org.pgpainless.bouncycastle.sop.operation.BCStatus;
import picocli.CommandLine;
import sop.Ready;
import sop.cli.picocli.SopCLI;
import sop.cli.picocli.commands.AbstractSopCmd;
import sop.exception.SOPGPException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
@CommandLine.Command(name = "status",
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
public class BCStatusCmd extends AbstractSopCmd {
@CommandLine.Parameters(arity = "0..1")
public String fileName;
@CommandLine.Option(names = {"--json"})
public boolean json = false;
@CommandLine.Option(names = {"--time"},
paramLabel = "UTC_TIME")
Date time = null;
@Override
public void run() {
BCStatus status = throwIfUnsupportedSubcommand(
((BouncyCastleSOP) SopCLI.getSop()).status(), "status");
InputStream in;
if (fileName != null) {
try {
in = getInput(fileName);
} catch (FileNotFoundException e) {
throw new SOPGPException.MissingInput("Could not find file " + fileName, e);
} catch (IOException e) {
throw new SOPGPException.BadData(e);
}
} else {
in = System.in;
}
Ready ready = status.json(json)
.time(time)
.cert(in);
try {
ready.writeTo(System.out);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}