sop-java/sop-java-picocli/src/main/java/sop/cli/picocli/commands/DearmorCmd.java

39 lines
1.1 KiB
Java
Raw Normal View History

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 java.io.IOException;
import picocli.CommandLine;
import sop.cli.picocli.Print;
import sop.cli.picocli.SopCLI;
import sop.exception.SOPGPException;
import sop.operation.Dearmor;
@CommandLine.Command(name = "dearmor",
description = "Remove ASCII Armor from standard input",
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) {
Print.errln("Bad data.");
Print.trace(e);
System.exit(e.getExitCode());
} catch (IOException e) {
Print.errln("IO Error.");
Print.trace(e);
System.exit(1);
}
}
}