mirror of
https://codeberg.org/PGPainless/bc-sop.git
synced 2025-09-10 11:49:40 +02:00
Add WIP status command
This commit is contained in:
parent
e0952aaf60
commit
4c58775f17
4 changed files with 119 additions and 13 deletions
58
bc-sop-cli/src/main/java/org/pgpainless/BCStatusCmd.java
Normal file
58
bc-sop-cli/src/main/java/org/pgpainless/BCStatusCmd.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue