mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-15 13:19:45 +02:00
Merge branch 'sharedResource'
This commit is contained in:
commit
092a83a1e7
44 changed files with 427 additions and 381 deletions
|
@ -26,7 +26,7 @@ import java.util.ResourceBundle;
|
|||
|
||||
@CommandLine.Command(
|
||||
name = "sop",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_sop",
|
||||
exitCodeOnInvalidInput = 69,
|
||||
subcommands = {
|
||||
CommandLine.HelpCommand.class,
|
||||
|
@ -48,7 +48,7 @@ import java.util.ResourceBundle;
|
|||
public class SopCLI {
|
||||
// Singleton
|
||||
static SOP SOP_INSTANCE;
|
||||
static ResourceBundle cliMsg = ResourceBundle.getBundle("sop");
|
||||
static ResourceBundle cliMsg = ResourceBundle.getBundle("msg_sop");
|
||||
|
||||
public static String EXECUTABLE_NAME = "sop";
|
||||
|
||||
|
@ -64,15 +64,20 @@ public class SopCLI {
|
|||
// Set locale
|
||||
new CommandLine(new InitLocale()).parseArgs(args);
|
||||
|
||||
cliMsg = ResourceBundle.getBundle("sop");
|
||||
// get error message bundle
|
||||
cliMsg = ResourceBundle.getBundle("msg_sop");
|
||||
|
||||
// Prepare CLI
|
||||
CommandLine cmd = new CommandLine(SopCLI.class);
|
||||
// Hide generate-completion command
|
||||
CommandLine gen = cmd.getSubcommands().get("generate-completion");
|
||||
gen.getCommandSpec().usageMessage().hidden(true);
|
||||
|
||||
cmd.setExecutionExceptionHandler(new SOPExecutionExceptionHandler())
|
||||
// explicitly set help command resource bundle
|
||||
cmd.getSubcommands().get("help").setResourceBundle(ResourceBundle.getBundle("msg_help"));
|
||||
|
||||
// Hide generate-completion command
|
||||
cmd.getSubcommands().get("generate-completion").getCommandSpec().usageMessage().hidden(true);
|
||||
|
||||
cmd.setCommandName(EXECUTABLE_NAME)
|
||||
.setExecutionExceptionHandler(new SOPExecutionExceptionHandler())
|
||||
.setExitCodeExceptionMapper(new SOPExceptionExitCodeMapper())
|
||||
.setCaseInsensitiveEnumValuesAllowed(true);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public abstract class AbstractSopCmd implements Runnable {
|
|||
}
|
||||
|
||||
public AbstractSopCmd(@Nonnull Locale locale) {
|
||||
messages = ResourceBundle.getBundle("sop", locale);
|
||||
messages = ResourceBundle.getBundle("msg_sop", locale);
|
||||
}
|
||||
|
||||
void throwIfOutputExists(String output) {
|
||||
|
|
|
@ -14,12 +14,11 @@ import sop.operation.Armor;
|
|||
import java.io.IOException;
|
||||
|
||||
@CommandLine.Command(name = "armor",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_armor",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
public class ArmorCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = {"--label"},
|
||||
descriptionKey = "sop.armor.usage.option.label",
|
||||
paramLabel = "{auto|sig|key|cert|message}")
|
||||
ArmorLabel label;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import sop.operation.Dearmor;
|
|||
import java.io.IOException;
|
||||
|
||||
@CommandLine.Command(name = "dearmor",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_dearmor",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
public class DearmorCmd extends AbstractSopCmd {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
@CommandLine.Command(name = "decrypt",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_decrypt",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
public class DecryptCmd extends AbstractSopCmd {
|
||||
|
||||
|
@ -40,50 +40,41 @@ public class DecryptCmd extends AbstractSopCmd {
|
|||
|
||||
@CommandLine.Option(
|
||||
names = {OPT_SESSION_KEY_OUT},
|
||||
descriptionKey = "sop.decrypt.usage.option.session_key_out",
|
||||
paramLabel = "SESSIONKEY")
|
||||
String sessionKeyOut;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {OPT_WITH_SESSION_KEY},
|
||||
descriptionKey = "sop.decrypt.usage.option.with_session_key",
|
||||
paramLabel = "SESSIONKEY")
|
||||
List<String> withSessionKey = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {OPT_WITH_PASSWORD},
|
||||
descriptionKey = "sop.decrypt.usage.option.with_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {OPT_VERIFY_OUT},
|
||||
descriptionKey = "sop.decrypt.usage.option.verify_out",
|
||||
paramLabel = "VERIFICATIONS")
|
||||
String verifyOut;
|
||||
|
||||
@CommandLine.Option(names = {OPT_VERIFY_WITH},
|
||||
descriptionKey = "sop.decrypt.usage.option.certs",
|
||||
paramLabel = "CERT")
|
||||
List<String> certs = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {OPT_NOT_BEFORE},
|
||||
descriptionKey = "sop.decrypt.usage.option.not_before",
|
||||
paramLabel = "DATE")
|
||||
String notBefore = "-";
|
||||
|
||||
@CommandLine.Option(names = {OPT_NOT_AFTER},
|
||||
descriptionKey = "sop.decrypt.usage.option.not_after",
|
||||
paramLabel = "DATE")
|
||||
String notAfter = "now";
|
||||
|
||||
@CommandLine.Parameters(index = "0..*",
|
||||
descriptionKey = "sop.decrypt.usage.param.keys",
|
||||
paramLabel = "KEY")
|
||||
List<String> keys = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {OPT_WITH_KEY_PASSWORD},
|
||||
descriptionKey = "sop.decrypt.usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withKeyPassword = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,37 +17,31 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@CommandLine.Command(name = "encrypt",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_encrypt",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class EncryptCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "sop.encrypt.usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Option(names = {"--as"},
|
||||
descriptionKey = "sop.encrypt.usage.option.type",
|
||||
paramLabel = "{binary|text}")
|
||||
EncryptAs type;
|
||||
|
||||
@CommandLine.Option(names = "--with-password",
|
||||
descriptionKey = "sop.encrypt.usage.option.with_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--sign-with",
|
||||
descriptionKey = "sop.encrypt.usage.option.sign_with",
|
||||
paramLabel = "KEY")
|
||||
List<String> signWith = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "sop.encrypt.usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withKeyPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "sop.encrypt.usage.param.certs",
|
||||
index = "0..*",
|
||||
@CommandLine.Parameters(index = "0..*",
|
||||
paramLabel = "CERTS")
|
||||
List<String> certs = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -13,12 +13,11 @@ import sop.exception.SOPGPException;
|
|||
import sop.operation.ExtractCert;
|
||||
|
||||
@CommandLine.Command(name = "extract-cert",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_extract-cert",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class ExtractCertCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "sop.extract-cert.usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
|
|
|
@ -15,20 +15,18 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@CommandLine.Command(name = "generate-key",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_generate-key",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class GenerateKeyCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "sop.generate-key.usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "sop.generate-key.usage.option.user_id")
|
||||
@CommandLine.Parameters(paramLabel = "USERID")
|
||||
List<String> userId = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "sop.generate-key.usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
String withKeyPassword;
|
||||
|
||||
|
|
|
@ -14,18 +14,16 @@ import java.io.IOException;
|
|||
import java.io.OutputStream;
|
||||
|
||||
@CommandLine.Command(name = "inline-detach",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_inline-detach",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
public class InlineDetachCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--signatures-out"},
|
||||
descriptionKey = "sop.inline-detach.usage.option.signatures_out",
|
||||
paramLabel = "SIGNATURES")
|
||||
String signaturesOut;
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "sop.inline-detach.usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
|
|
|
@ -17,26 +17,22 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@CommandLine.Command(name = "inline-sign",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_inline-sign",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class InlineSignCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "sop.inline-sign.usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Option(names = "--as",
|
||||
descriptionKey = "sop.inline-sign.usage.option.as",
|
||||
paramLabel = "{binary|text|cleartextsigned}")
|
||||
InlineSignAs type;
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "sop.inline-sign.usage.parameter.keys",
|
||||
paramLabel = "KEYS")
|
||||
@CommandLine.Parameters(paramLabel = "KEYS")
|
||||
List<String> secretKeyFile = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "sop.inline-sign.usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withKeyPassword = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -19,27 +19,23 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@CommandLine.Command(name = "inline-verify",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_inline-verify",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class InlineVerifyCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Parameters(arity = "1..*",
|
||||
descriptionKey = "sop.inline-verify.usage.parameter.certs",
|
||||
paramLabel = "CERT")
|
||||
List<String> certificates = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {"--not-before"},
|
||||
descriptionKey = "sop.inline-verify.usage.option.not_before",
|
||||
paramLabel = "DATE")
|
||||
String notBefore = "-";
|
||||
|
||||
@CommandLine.Option(names = {"--not-after"},
|
||||
descriptionKey = "sop.inline-verify.usage.option.not_after",
|
||||
paramLabel = "DATE")
|
||||
String notAfter = "now";
|
||||
|
||||
@CommandLine.Option(names = "--verifications-out",
|
||||
descriptionKey = "sop.inline-verify.usage.option.verifications_out")
|
||||
@CommandLine.Option(names = "--verifications-out")
|
||||
String verificationsOut;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,31 +20,26 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@CommandLine.Command(name = "sign",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_detached-sign",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class SignCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "sop.sign.usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Option(names = "--as",
|
||||
descriptionKey = "sop.sign.usage.option.as",
|
||||
paramLabel = "{binary|text}")
|
||||
SignAs type;
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "sop.sign.usage.parameter.keys",
|
||||
paramLabel = "KEYS")
|
||||
@CommandLine.Parameters(paramLabel = "KEYS")
|
||||
List<String> secretKeyFile = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "sop.sign.usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withKeyPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--micalg-out",
|
||||
descriptionKey = "sop.sign.usage.option.micalg_out",
|
||||
paramLabel = "MICALG")
|
||||
String micAlgOut;
|
||||
|
||||
|
|
|
@ -17,28 +17,24 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@CommandLine.Command(name = "verify",
|
||||
resourceBundle = "sop",
|
||||
resourceBundle = "msg_detached-verify",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class VerifyCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Parameters(index = "0",
|
||||
descriptionKey = "sop.verify.usage.parameter.signature",
|
||||
paramLabel = "SIGNATURE")
|
||||
String signature;
|
||||
|
||||
@CommandLine.Parameters(index = "0..*",
|
||||
arity = "1..*",
|
||||
descriptionKey = "sop.verify.usage.parameter.certs",
|
||||
paramLabel = "CERT")
|
||||
List<String> certificates = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {"--not-before"},
|
||||
descriptionKey = "sop.verify.usage.option.not_before",
|
||||
paramLabel = "DATE")
|
||||
String notBefore = "-";
|
||||
|
||||
@CommandLine.Option(names = {"--not-after"},
|
||||
descriptionKey = "sop.verify.usage.option.not_after",
|
||||
paramLabel = "DATE")
|
||||
String notAfter = "now";
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import sop.cli.picocli.Print;
|
|||
import sop.cli.picocli.SopCLI;
|
||||
import sop.operation.Version;
|
||||
|
||||
@CommandLine.Command(name = "version", resourceBundle = "sop",
|
||||
@CommandLine.Command(name = "version", resourceBundle = "msg_version",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class VersionCmd extends AbstractSopCmd {
|
||||
|
||||
|
@ -17,12 +17,10 @@ public class VersionCmd extends AbstractSopCmd {
|
|||
Exclusive exclusive;
|
||||
|
||||
static class Exclusive {
|
||||
@CommandLine.Option(names = "--extended",
|
||||
descriptionKey = "sop.version.usage.option.extended")
|
||||
@CommandLine.Option(names = "--extended")
|
||||
boolean extended;
|
||||
|
||||
@CommandLine.Option(names = "--backend",
|
||||
descriptionKey = "sop.version.usage.option.backend")
|
||||
@CommandLine.Option(names = "--backend")
|
||||
boolean backend;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue