2022-01-11 13:46:05 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package sop.cli.picocli.commands;
|
|
|
|
|
|
|
|
import picocli.CommandLine;
|
|
|
|
import sop.cli.picocli.SopCLI;
|
|
|
|
import sop.exception.SOPGPException;
|
|
|
|
import sop.operation.Dearmor;
|
|
|
|
|
2022-06-06 20:06:14 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2022-01-11 13:46:05 +01:00
|
|
|
@CommandLine.Command(name = "dearmor",
|
2022-07-25 19:15:47 +02:00
|
|
|
resourceBundle = "dearmor",
|
2022-01-11 13:46:05 +01:00
|
|
|
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
2022-05-29 21:17:03 +02:00
|
|
|
public class DearmorCmd extends AbstractSopCmd {
|
2022-01-11 13:46:05 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2022-05-29 21:17:03 +02:00
|
|
|
Dearmor dearmor = throwIfUnsupportedSubcommand(
|
|
|
|
SopCLI.getSop().dearmor(), "dearmor");
|
2022-01-11 13:46:05 +01:00
|
|
|
|
|
|
|
try {
|
2022-05-29 21:17:03 +02:00
|
|
|
dearmor.data(System.in)
|
2022-01-11 13:46:05 +01:00
|
|
|
.writeTo(System.out);
|
|
|
|
} catch (SOPGPException.BadData e) {
|
2022-06-06 20:06:14 +02:00
|
|
|
String errorMsg = getMsg("sop.error.input.stdin_not_openpgp_data");
|
|
|
|
throw new SOPGPException.BadData(errorMsg, e);
|
2022-01-11 13:46:05 +01:00
|
|
|
} catch (IOException e) {
|
2022-06-06 20:06:14 +02:00
|
|
|
throw new RuntimeException(e);
|
2022-01-11 13:46:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|