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); } } }