Split message resources into separate per-command resource files.

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
This commit is contained in:
Paul Schaub 2022-07-25 19:15:47 +02:00
parent 3801a644ef
commit fa52df385e
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
39 changed files with 307 additions and 230 deletions

View file

@ -14,12 +14,12 @@ import sop.operation.Armor;
import java.io.IOException;
@CommandLine.Command(name = "armor",
resourceBundle = "sop",
resourceBundle = "armor",
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
public class ArmorCmd extends AbstractSopCmd {
@CommandLine.Option(names = {"--label"},
descriptionKey = "sop.armor.usage.option.label",
descriptionKey = "usage.option.label",
paramLabel = "{auto|sig|key|cert|message}")
ArmorLabel label;

View file

@ -12,7 +12,7 @@ import sop.operation.Dearmor;
import java.io.IOException;
@CommandLine.Command(name = "dearmor",
resourceBundle = "sop",
resourceBundle = "dearmor",
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
public class DearmorCmd extends AbstractSopCmd {

View file

@ -24,7 +24,7 @@ import java.util.List;
import java.util.regex.Pattern;
@CommandLine.Command(name = "decrypt",
resourceBundle = "sop",
resourceBundle = "decrypt",
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
public class DecryptCmd extends AbstractSopCmd {
@ -40,49 +40,49 @@ public class DecryptCmd extends AbstractSopCmd {
@CommandLine.Option(
names = {OPT_SESSION_KEY_OUT},
descriptionKey = "sop.decrypt.usage.option.session_key_out",
descriptionKey = "usage.option.session_key_out",
paramLabel = "SESSIONKEY")
String sessionKeyOut;
@CommandLine.Option(
names = {OPT_WITH_SESSION_KEY},
descriptionKey = "sop.decrypt.usage.option.with_session_key",
descriptionKey = "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",
descriptionKey = "usage.option.with_password",
paramLabel = "PASSWORD")
List<String> withPassword = new ArrayList<>();
@CommandLine.Option(names = {OPT_VERIFY_OUT},
descriptionKey = "sop.decrypt.usage.option.verify_out",
descriptionKey = "usage.option.verify_out",
paramLabel = "VERIFICATIONS")
String verifyOut;
@CommandLine.Option(names = {OPT_VERIFY_WITH},
descriptionKey = "sop.decrypt.usage.option.certs",
descriptionKey = "usage.option.certs",
paramLabel = "CERT")
List<String> certs = new ArrayList<>();
@CommandLine.Option(names = {OPT_NOT_BEFORE},
descriptionKey = "sop.decrypt.usage.option.not_before",
descriptionKey = "usage.option.not_before",
paramLabel = "DATE")
String notBefore = "-";
@CommandLine.Option(names = {OPT_NOT_AFTER},
descriptionKey = "sop.decrypt.usage.option.not_after",
descriptionKey = "usage.option.not_after",
paramLabel = "DATE")
String notAfter = "now";
@CommandLine.Parameters(index = "0..*",
descriptionKey = "sop.decrypt.usage.param.keys",
descriptionKey = "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",
descriptionKey = "usage.option.with_key_password",
paramLabel = "PASSWORD")
List<String> withKeyPassword = new ArrayList<>();

View file

@ -17,36 +17,36 @@ import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "encrypt",
resourceBundle = "sop",
resourceBundle = "encrypt",
exitCodeOnInvalidInput = 37)
public class EncryptCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--no-armor",
descriptionKey = "sop.encrypt.usage.option.armor",
descriptionKey = "usage.option.armor",
negatable = true)
boolean armor = true;
@CommandLine.Option(names = {"--as"},
descriptionKey = "sop.encrypt.usage.option.type",
descriptionKey = "usage.option.type",
paramLabel = "{binary|text}")
EncryptAs type;
@CommandLine.Option(names = "--with-password",
descriptionKey = "sop.encrypt.usage.option.with_password",
descriptionKey = "usage.option.with_password",
paramLabel = "PASSWORD")
List<String> withPassword = new ArrayList<>();
@CommandLine.Option(names = "--sign-with",
descriptionKey = "sop.encrypt.usage.option.sign_with",
descriptionKey = "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",
descriptionKey = "usage.option.with_key_password",
paramLabel = "PASSWORD")
List<String> withKeyPassword = new ArrayList<>();
@CommandLine.Parameters(descriptionKey = "sop.encrypt.usage.param.certs",
@CommandLine.Parameters(descriptionKey = "usage.param.certs",
index = "0..*",
paramLabel = "CERTS")
List<String> certs = new ArrayList<>();

View file

@ -13,12 +13,12 @@ import sop.exception.SOPGPException;
import sop.operation.ExtractCert;
@CommandLine.Command(name = "extract-cert",
resourceBundle = "sop",
resourceBundle = "extract-cert",
exitCodeOnInvalidInput = 37)
public class ExtractCertCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--no-armor",
descriptionKey = "sop.extract-cert.usage.option.armor",
descriptionKey = "usage.option.armor",
negatable = true)
boolean armor = true;

View file

@ -15,20 +15,20 @@ import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "generate-key",
resourceBundle = "sop",
resourceBundle = "generate-key",
exitCodeOnInvalidInput = 37)
public class GenerateKeyCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--no-armor",
descriptionKey = "sop.generate-key.usage.option.armor",
descriptionKey = "usage.option.armor",
negatable = true)
boolean armor = true;
@CommandLine.Parameters(descriptionKey = "sop.generate-key.usage.option.user_id")
@CommandLine.Parameters(descriptionKey = "usage.option.user_id")
List<String> userId = new ArrayList<>();
@CommandLine.Option(names = "--with-key-password",
descriptionKey = "sop.generate-key.usage.option.with_key_password",
descriptionKey = "usage.option.with_key_password",
paramLabel = "PASSWORD")
String withKeyPassword;

View file

@ -14,18 +14,18 @@ import java.io.IOException;
import java.io.OutputStream;
@CommandLine.Command(name = "inline-detach",
resourceBundle = "sop",
resourceBundle = "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",
descriptionKey = "usage.option.signatures_out",
paramLabel = "SIGNATURES")
String signaturesOut;
@CommandLine.Option(names = "--no-armor",
descriptionKey = "sop.inline-detach.usage.option.armor",
descriptionKey = "usage.option.armor",
negatable = true)
boolean armor = true;

View file

@ -17,26 +17,26 @@ import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "inline-sign",
resourceBundle = "sop",
resourceBundle = "inline-sign",
exitCodeOnInvalidInput = 37)
public class InlineSignCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--no-armor",
descriptionKey = "sop.inline-sign.usage.option.armor",
descriptionKey = "usage.option.armor",
negatable = true)
boolean armor = true;
@CommandLine.Option(names = "--as",
descriptionKey = "sop.inline-sign.usage.option.as",
descriptionKey = "usage.option.as",
paramLabel = "{binary|text|cleartextsigned}")
InlineSignAs type;
@CommandLine.Parameters(descriptionKey = "sop.inline-sign.usage.parameter.keys",
@CommandLine.Parameters(descriptionKey = "usage.parameter.keys",
paramLabel = "KEYS")
List<String> secretKeyFile = new ArrayList<>();
@CommandLine.Option(names = "--with-key-password",
descriptionKey = "sop.inline-sign.usage.option.with_key_password",
descriptionKey = "usage.option.with_key_password",
paramLabel = "PASSWORD")
List<String> withKeyPassword = new ArrayList<>();

View file

@ -19,27 +19,27 @@ import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "inline-verify",
resourceBundle = "sop",
resourceBundle = "inline-verify",
exitCodeOnInvalidInput = 37)
public class InlineVerifyCmd extends AbstractSopCmd {
@CommandLine.Parameters(arity = "1..*",
descriptionKey = "sop.inline-verify.usage.parameter.certs",
descriptionKey = "usage.parameter.certs",
paramLabel = "CERT")
List<String> certificates = new ArrayList<>();
@CommandLine.Option(names = {"--not-before"},
descriptionKey = "sop.inline-verify.usage.option.not_before",
descriptionKey = "usage.option.not_before",
paramLabel = "DATE")
String notBefore = "-";
@CommandLine.Option(names = {"--not-after"},
descriptionKey = "sop.inline-verify.usage.option.not_after",
descriptionKey = "usage.option.not_after",
paramLabel = "DATE")
String notAfter = "now";
@CommandLine.Option(names = "--verifications-out",
descriptionKey = "sop.inline-verify.usage.option.verifications_out")
descriptionKey = "usage.option.verifications_out")
String verificationsOut;
@Override

View file

@ -20,31 +20,31 @@ import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "sign",
resourceBundle = "sop",
resourceBundle = "detached-sign",
exitCodeOnInvalidInput = 37)
public class SignCmd extends AbstractSopCmd {
@CommandLine.Option(names = "--no-armor",
descriptionKey = "sop.sign.usage.option.armor",
descriptionKey = "usage.option.armor",
negatable = true)
boolean armor = true;
@CommandLine.Option(names = "--as",
descriptionKey = "sop.sign.usage.option.as",
descriptionKey = "usage.option.as",
paramLabel = "{binary|text}")
SignAs type;
@CommandLine.Parameters(descriptionKey = "sop.sign.usage.parameter.keys",
@CommandLine.Parameters(descriptionKey = "usage.parameter.keys",
paramLabel = "KEYS")
List<String> secretKeyFile = new ArrayList<>();
@CommandLine.Option(names = "--with-key-password",
descriptionKey = "sop.sign.usage.option.with_key_password",
descriptionKey = "usage.option.with_key_password",
paramLabel = "PASSWORD")
List<String> withKeyPassword = new ArrayList<>();
@CommandLine.Option(names = "--micalg-out",
descriptionKey = "sop.sign.usage.option.micalg_out",
descriptionKey = "usage.option.micalg_out",
paramLabel = "MICALG")
String micAlgOut;

View file

@ -17,28 +17,28 @@ import java.util.ArrayList;
import java.util.List;
@CommandLine.Command(name = "verify",
resourceBundle = "sop",
resourceBundle = "detached-verify",
exitCodeOnInvalidInput = 37)
public class VerifyCmd extends AbstractSopCmd {
@CommandLine.Parameters(index = "0",
descriptionKey = "sop.verify.usage.parameter.signature",
descriptionKey = "usage.parameter.signature",
paramLabel = "SIGNATURE")
String signature;
@CommandLine.Parameters(index = "0..*",
arity = "1..*",
descriptionKey = "sop.verify.usage.parameter.certs",
descriptionKey = "usage.parameter.certs",
paramLabel = "CERT")
List<String> certificates = new ArrayList<>();
@CommandLine.Option(names = {"--not-before"},
descriptionKey = "sop.verify.usage.option.not_before",
descriptionKey = "usage.option.not_before",
paramLabel = "DATE")
String notBefore = "-";
@CommandLine.Option(names = {"--not-after"},
descriptionKey = "sop.verify.usage.option.not_after",
descriptionKey = "usage.option.not_after",
paramLabel = "DATE")
String notAfter = "now";

View file

@ -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 = "version",
exitCodeOnInvalidInput = 37)
public class VersionCmd extends AbstractSopCmd {
@ -18,11 +18,11 @@ public class VersionCmd extends AbstractSopCmd {
static class Exclusive {
@CommandLine.Option(names = "--extended",
descriptionKey = "sop.version.usage.option.extended")
descriptionKey = "usage.option.extended")
boolean extended;
@CommandLine.Option(names = "--backend",
descriptionKey = "sop.version.usage.option.backend")
descriptionKey = "usage.option.backend")
boolean backend;
}