mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-10 10:49:48 +02:00
Rename resource bundles and name resources after options/parameters
This commit is contained in:
parent
7de94f1815
commit
dc5f11469f
56 changed files with 229 additions and 269 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";
|
||||
|
||||
|
@ -65,13 +65,13 @@ public class SopCLI {
|
|||
new CommandLine(new InitLocale()).parseArgs(args);
|
||||
|
||||
// get error message bundle
|
||||
cliMsg = ResourceBundle.getBundle("sop");
|
||||
cliMsg = ResourceBundle.getBundle("msg_sop");
|
||||
|
||||
// Prepare CLI
|
||||
CommandLine cmd = new CommandLine(SopCLI.class);
|
||||
|
||||
// explicitly set help command resource bundle
|
||||
cmd.getSubcommands().get("help").setResourceBundle(ResourceBundle.getBundle("help"));
|
||||
cmd.getSubcommands().get("help").setResourceBundle(ResourceBundle.getBundle("msg_help"));
|
||||
|
||||
// Hide generate-completion command
|
||||
cmd.getSubcommands().get("generate-completion").getCommandSpec().usageMessage().hidden(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 = "armor",
|
||||
resourceBundle = "msg_armor",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
public class ArmorCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = {"--label"},
|
||||
descriptionKey = "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 = "dearmor",
|
||||
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 = "decrypt",
|
||||
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 = "usage.option.session_key_out",
|
||||
paramLabel = "SESSIONKEY")
|
||||
String sessionKeyOut;
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {OPT_WITH_SESSION_KEY},
|
||||
descriptionKey = "usage.option.with_session_key",
|
||||
paramLabel = "SESSIONKEY")
|
||||
List<String> withSessionKey = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {OPT_WITH_PASSWORD},
|
||||
descriptionKey = "usage.option.with_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {OPT_VERIFY_OUT},
|
||||
descriptionKey = "usage.option.verify_out",
|
||||
paramLabel = "VERIFICATIONS")
|
||||
String verifyOut;
|
||||
|
||||
@CommandLine.Option(names = {OPT_VERIFY_WITH},
|
||||
descriptionKey = "usage.option.certs",
|
||||
paramLabel = "CERT")
|
||||
List<String> certs = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {OPT_NOT_BEFORE},
|
||||
descriptionKey = "usage.option.not_before",
|
||||
paramLabel = "DATE")
|
||||
String notBefore = "-";
|
||||
|
||||
@CommandLine.Option(names = {OPT_NOT_AFTER},
|
||||
descriptionKey = "usage.option.not_after",
|
||||
paramLabel = "DATE")
|
||||
String notAfter = "now";
|
||||
|
||||
@CommandLine.Parameters(index = "0..*",
|
||||
descriptionKey = "usage.param.keys",
|
||||
paramLabel = "KEY")
|
||||
List<String> keys = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {OPT_WITH_KEY_PASSWORD},
|
||||
descriptionKey = "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 = "encrypt",
|
||||
resourceBundle = "msg_encrypt",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class EncryptCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Option(names = {"--as"},
|
||||
descriptionKey = "usage.option.type",
|
||||
paramLabel = "{binary|text}")
|
||||
EncryptAs type;
|
||||
|
||||
@CommandLine.Option(names = "--with-password",
|
||||
descriptionKey = "usage.option.with_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--sign-with",
|
||||
descriptionKey = "usage.option.sign_with",
|
||||
paramLabel = "KEY")
|
||||
List<String> signWith = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withKeyPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "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 = "extract-cert",
|
||||
resourceBundle = "msg_extract-cert",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class ExtractCertCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "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 = "generate-key",
|
||||
resourceBundle = "msg_generate-key",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class GenerateKeyCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "usage.option.user_id")
|
||||
@CommandLine.Parameters
|
||||
List<String> userId = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "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 = "inline-detach",
|
||||
resourceBundle = "msg_inline-detach",
|
||||
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
|
||||
public class InlineDetachCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(
|
||||
names = {"--signatures-out"},
|
||||
descriptionKey = "usage.option.signatures_out",
|
||||
paramLabel = "SIGNATURES")
|
||||
String signaturesOut;
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "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 = "inline-sign",
|
||||
resourceBundle = "msg_inline-sign",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class InlineSignCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Option(names = "--as",
|
||||
descriptionKey = "usage.option.as",
|
||||
paramLabel = "{binary|text|cleartextsigned}")
|
||||
InlineSignAs type;
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "usage.parameter.keys",
|
||||
paramLabel = "KEYS")
|
||||
@CommandLine.Parameters(paramLabel = "KEYS")
|
||||
List<String> secretKeyFile = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "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 = "inline-verify",
|
||||
resourceBundle = "msg_inline-verify",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class InlineVerifyCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Parameters(arity = "1..*",
|
||||
descriptionKey = "usage.parameter.certs",
|
||||
paramLabel = "CERT")
|
||||
List<String> certificates = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {"--not-before"},
|
||||
descriptionKey = "usage.option.not_before",
|
||||
paramLabel = "DATE")
|
||||
String notBefore = "-";
|
||||
|
||||
@CommandLine.Option(names = {"--not-after"},
|
||||
descriptionKey = "usage.option.not_after",
|
||||
paramLabel = "DATE")
|
||||
String notAfter = "now";
|
||||
|
||||
@CommandLine.Option(names = "--verifications-out",
|
||||
descriptionKey = "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 = "detached-sign",
|
||||
resourceBundle = "msg_detached-sign",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class SignCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Option(names = "--no-armor",
|
||||
descriptionKey = "usage.option.armor",
|
||||
negatable = true)
|
||||
boolean armor = true;
|
||||
|
||||
@CommandLine.Option(names = "--as",
|
||||
descriptionKey = "usage.option.as",
|
||||
paramLabel = "{binary|text}")
|
||||
SignAs type;
|
||||
|
||||
@CommandLine.Parameters(descriptionKey = "usage.parameter.keys",
|
||||
paramLabel = "KEYS")
|
||||
@CommandLine.Parameters(paramLabel = "KEYS")
|
||||
List<String> secretKeyFile = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--with-key-password",
|
||||
descriptionKey = "usage.option.with_key_password",
|
||||
paramLabel = "PASSWORD")
|
||||
List<String> withKeyPassword = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = "--micalg-out",
|
||||
descriptionKey = "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 = "detached-verify",
|
||||
resourceBundle = "msg_detached-verify",
|
||||
exitCodeOnInvalidInput = 37)
|
||||
public class VerifyCmd extends AbstractSopCmd {
|
||||
|
||||
@CommandLine.Parameters(index = "0",
|
||||
descriptionKey = "usage.parameter.signature",
|
||||
paramLabel = "SIGNATURE")
|
||||
String signature;
|
||||
|
||||
@CommandLine.Parameters(index = "0..*",
|
||||
arity = "1..*",
|
||||
descriptionKey = "usage.parameter.certs",
|
||||
paramLabel = "CERT")
|
||||
List<String> certificates = new ArrayList<>();
|
||||
|
||||
@CommandLine.Option(names = {"--not-before"},
|
||||
descriptionKey = "usage.option.not_before",
|
||||
paramLabel = "DATE")
|
||||
String notBefore = "-";
|
||||
|
||||
@CommandLine.Option(names = {"--not-after"},
|
||||
descriptionKey = "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 = "version",
|
||||
@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 = "usage.option.extended")
|
||||
@CommandLine.Option(names = "--extended")
|
||||
boolean extended;
|
||||
|
||||
@CommandLine.Option(names = "--backend",
|
||||
descriptionKey = "usage.option.backend")
|
||||
@CommandLine.Option(names = "--backend")
|
||||
boolean backend;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue