mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-06-25 04:54:54 +02:00
Since picocli 4.7.0, subcommands inherit resources from their parent commands, so we can store shared stuff like error msgs etc. in the parent (sop) resources file. This enables us to rename the parent command downstream (e.g. in pgpainless-cli). Only the help command breaks when renaming the parent command. TODO: Fix
35 lines
1 KiB
Java
35 lines
1 KiB
Java
// 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;
|
|
|
|
import java.io.IOException;
|
|
|
|
@CommandLine.Command(name = "dearmor",
|
|
resourceBundle = "dearmor",
|
|
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
|
public class DearmorCmd extends AbstractSopCmd {
|
|
|
|
@Override
|
|
public void run() {
|
|
Dearmor dearmor = throwIfUnsupportedSubcommand(
|
|
SopCLI.getSop().dearmor(), "dearmor");
|
|
|
|
try {
|
|
dearmor.data(System.in)
|
|
.writeTo(System.out);
|
|
} catch (SOPGPException.BadData e) {
|
|
String errorMsg = getMsg("sop.error.input.stdin_not_openpgp_data");
|
|
throw new SOPGPException.BadData(errorMsg, e);
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|