diff --git a/vks-java-cli/src/main/java/pgp/vks/client/cli/GetCmd.java b/vks-java-cli/src/main/java/pgp/vks/client/cli/GetCmd.java index 7f1fa9f..43ea165 100644 --- a/vks-java-cli/src/main/java/pgp/vks/client/cli/GetCmd.java +++ b/vks-java-cli/src/main/java/pgp/vks/client/cli/GetCmd.java @@ -11,8 +11,12 @@ import picocli.CommandLine; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; +import java.util.Locale; +import java.util.ResourceBundle; -@CommandLine.Command(name = "get", description = "Retrieve an OpenPGP certificate from the key server") +@CommandLine.Command( + name = "get", + resourceBundle = "msg_get") public class GetCmd implements Runnable { @CommandLine.Mixin @@ -22,16 +26,22 @@ public class GetCmd implements Runnable { Exclusive by; static class Exclusive { - @CommandLine.Option(names = {"-f", "--by-fingerprint"}, description = "Retrieve a key by its fingerprint (NOT prefixed with '0x')") + @CommandLine.Option(names = {"-f", "--by-fingerprint"}) String fingerprint; - @CommandLine.Option(names = {"-i", "--by-keyid"}, description = "Retrieve a key by its decimal key ID or that of one of its subkeys.") + @CommandLine.Option(names = {"-i", "--by-keyid"}) Long keyId; - @CommandLine.Option(names = {"-e", "--by-email"}, description = "Retrieve a key by email address.") + @CommandLine.Option(names = {"-e", "--by-email"}) String email; } + private final ResourceBundle msg; + + public GetCmd() { + msg = ResourceBundle.getBundle("msg_get", Locale.getDefault()); + } + public void run() { VKS vks; try { @@ -50,7 +60,7 @@ public class GetCmd implements Runnable { } else if (by.email != null) { inputStream = get.byEmail(by.email); } else { - throw new IllegalArgumentException("Missing --by-* option."); + throw new IllegalArgumentException(msg.getString("error.missing_by_option")); } int read; diff --git a/vks-java-cli/src/main/java/pgp/vks/client/cli/RequestVerificationCmd.java b/vks-java-cli/src/main/java/pgp/vks/client/cli/RequestVerificationCmd.java index 6767f7d..2fba390 100644 --- a/vks-java-cli/src/main/java/pgp/vks/client/cli/RequestVerificationCmd.java +++ b/vks-java-cli/src/main/java/pgp/vks/client/cli/RequestVerificationCmd.java @@ -12,23 +12,32 @@ import java.io.IOException; import java.net.MalformedURLException; import java.util.Arrays; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; -@CommandLine.Command(name = "request-verification", description = "Request verification for unverified user-ids") +@CommandLine.Command( + name = "request-verification", + resourceBundle = "msg_request_verification") public class RequestVerificationCmd implements Runnable { @CommandLine.Mixin VKSCLI.KeyServerMixin keyServerMixin; - @CommandLine.Option(names = {"-t", "--token"}, description = "Access token. Can be retrieved by uploading the certificate.", + @CommandLine.Option(names = {"-t", "--token"}, required = true, arity = "1", paramLabel = "TOKEN") String token; - @CommandLine.Option(names = {"-l", "--locale"}, description = "Locale for the verification mail") + @CommandLine.Option(names = {"-l", "--locale"}) List locale = Arrays.asList("en_US", "en_GB"); - @CommandLine.Option(names = {"-e", "--email"}, description = "Email addresses to request a verification mail for", required = true, arity = "1..*") + @CommandLine.Option(names = {"-e", "--email"}, required = true, arity = "1..*") String[] addresses = new String[0]; + private final ResourceBundle msg; + + public RequestVerificationCmd() { + msg = ResourceBundle.getBundle("msg_request_verification", Locale.getDefault()); + } @Override public void run() { @@ -44,10 +53,9 @@ public class RequestVerificationCmd implements Runnable { RequestVerify.Response response = requestVerify .forEmailAddresses(addresses) .execute(token, locale); - - System.out.println("Verification E-Mails for key " + response.getKeyFingerprint() + " have been sent."); - System.out.println("Token: " + response.getToken()); - System.out.println("Status:"); + System.out.printf(msg.getString("output.mails_sent"), response.getKeyFingerprint()); + System.out.printf(msg.getString("output.token"), response.getToken()); + System.out.println(msg.getString("output.status")); for (String address : response.getStatus().keySet()) { System.out.println("\t" + address + "\t" + response.getStatus().get(address)); } diff --git a/vks-java-cli/src/main/java/pgp/vks/client/cli/UploadCmd.java b/vks-java-cli/src/main/java/pgp/vks/client/cli/UploadCmd.java index cba61bb..c3927bc 100644 --- a/vks-java-cli/src/main/java/pgp/vks/client/cli/UploadCmd.java +++ b/vks-java-cli/src/main/java/pgp/vks/client/cli/UploadCmd.java @@ -15,17 +15,26 @@ import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; -@CommandLine.Command(name = "upload", description = "Upload an OpenPGP certificate to the key server") +@CommandLine.Command( + name = "upload", + resourceBundle = "msg_upload") public class UploadCmd implements Runnable { @CommandLine.Mixin VKSCLI.KeyServerMixin keyServerMixin; - @CommandLine.Option(names = {"-r", "--request-verification"}, - description = "Request verification mails for unpublished email addresses") + @CommandLine.Option(names = {"-r", "--request-verification"}) boolean requestVerification; + private final ResourceBundle msg; + + public UploadCmd() { + msg = ResourceBundle.getBundle("msg_upload", Locale.getDefault()); + } + public void run() { VKS vks; try { @@ -51,11 +60,13 @@ public class UploadCmd implements Runnable { } } - System.out.println("Uploaded key " + response.getKeyFingerprint()); - System.out.println("Token: " + response.getToken()); + String msgUpload = String.format(msg.getString("output.uploaded_key"), + response.getKeyFingerprint(), response.getToken()); + System.out.println(msgUpload); + String msgStatus = msg.getString("output.status"); if (!requestVerification || unpublished.isEmpty()) { - System.out.println("Status:"); + System.out.println(msgStatus); for (String address : response.getStatus().keySet()) { Status status = response.getStatus().get(address); System.out.format("%-" + maxMailLen + "s %s\n", address, status); @@ -65,7 +76,7 @@ public class UploadCmd implements Runnable { RequestVerify.Response verifyResponse = vks.requestVerification().forEmailAddresses(unpublished.toArray(new String[0])) .execute(response.getToken()); - System.out.println("Status:"); + System.out.println(msgStatus); for (String address : verifyResponse.getStatus().keySet()) { Status status = response.getStatus().get(address); System.out.format("%-" + maxMailLen + "s %s\n", address, status); diff --git a/vks-java-cli/src/main/java/pgp/vks/client/cli/VKSCLI.java b/vks-java-cli/src/main/java/pgp/vks/client/cli/VKSCLI.java index dec9f39..142e192 100644 --- a/vks-java-cli/src/main/java/pgp/vks/client/cli/VKSCLI.java +++ b/vks-java-cli/src/main/java/pgp/vks/client/cli/VKSCLI.java @@ -9,10 +9,12 @@ import pgp.vks.client.VKSImpl; import picocli.CommandLine; import java.net.MalformedURLException; +import java.util.Locale; +import java.util.ResourceBundle; @CommandLine.Command( name = "vks", - description = "Interact with Verifying Key Servers", + resourceBundle = "msg_vks", subcommands = { CommandLine.HelpCommand.class, GetCmd.class, @@ -32,14 +34,15 @@ public class VKSCLI { } public static int execute(String[] args) { - return new CommandLine(VKSCLI.class) - .setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() { + CommandLine cmd = new CommandLine(VKSCLI.class); + cmd.setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() { @Override public int getExitCode(Throwable exception) { return 1; } - }) - .setCommandName("vkscli") + }); + cmd.getSubcommands().get("help").setResourceBundle(ResourceBundle.getBundle("msg_help", Locale.getDefault())); + return cmd.setCommandName("vkscli") .execute(args); } @@ -53,7 +56,6 @@ public class VKSCLI { VKSCLI parent; @CommandLine.Option(names = "--key-server", - description = "Address of the Verifying Key Server.\nDefaults to 'https://keys.openpgp.org'", paramLabel = "KEYSERVER") public void setKeyServer(String keyServer) { parent.keyServer = keyServer; diff --git a/vks-java-cli/src/main/resources/msg_get.properties b/vks-java-cli/src/main/resources/msg_get.properties new file mode 100644 index 0000000..70ab33d --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_get.properties @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Retrieve an OpenPGP certificate from the key server +by-fingerprint=Retrieve a key by its fingerprint (NOT prefixed with '0x') +by-keyid=Retrieve a key by its decimal key ID or that of one of its subkeys +by-email=Retrieve a key by email address +error.missing_by_option=Missing --by-* option. +key-server=Address of the Verifying Key Server.%nDefaults to 'https://keys.openpgp.org' diff --git a/vks-java-cli/src/main/resources/msg_get_de.properties b/vks-java-cli/src/main/resources/msg_get_de.properties new file mode 100644 index 0000000..b13c717 --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_get_de.properties @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Empfange ein OpenPGP Zertifikat vom Schlüsselserver +by-fingerprint=Finde das Zertifikat anhand seines Fingerabdrucks (OHNE Präfix '0x') +by-keyid=Finde das Zertifikat anhand seiner Schlüssel-ID oder der eines seiner Unterschlüssel +by-email=Finde das Zertifikat anhand einer E-Mail-Adresse +error.missing_by_option=Fehlende --by-* Option. +usage.synopsisHeading=Nutzung:\u0020 +usage.optionListHeading=Optionen:%n + +key-server=Adresse des verifizierenden Schlüsselservers.%nStandardmäßig: 'https://keys.openpgp.org' diff --git a/vks-java-cli/src/main/resources/msg_help.properties b/vks-java-cli/src/main/resources/msg_help.properties new file mode 100644 index 0000000..f288ae3 --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_help.properties @@ -0,0 +1,5 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Displays help information about the specified command +usage.synopsisHeading=Usage:\u0020 diff --git a/vks-java-cli/src/main/resources/msg_help_de.properties b/vks-java-cli/src/main/resources/msg_help_de.properties new file mode 100644 index 0000000..304bb42 --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_help_de.properties @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Zeige Hilfetext für den angegebenen Befehl +usage.synopsisHeading=Nutzung:\u0020 +usage.optionListHeading=Optionen:%n diff --git a/vks-java-cli/src/main/resources/msg_request_verification.properties b/vks-java-cli/src/main/resources/msg_request_verification.properties new file mode 100644 index 0000000..b8d64ae --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_request_verification.properties @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Request verification for unverified user-ids +token=Access token. Can be retrieved by uploading the certificate. +locale=Locale (language) for the verification mail +email=Email addresses to request a verification mail for +output.mails_sent=Verification E-Mails for certificate %s have been sent.%n +output.token=Token: %s%n +output.status=Status: +key-server=Address of the Verifying Key Server.%nDefaults to 'https://keys.openpgp.org' diff --git a/vks-java-cli/src/main/resources/msg_request_verification_de.properties b/vks-java-cli/src/main/resources/msg_request_verification_de.properties new file mode 100644 index 0000000..773630c --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_request_verification_de.properties @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Fordere Verifikation von unveröffentlichten Nutzeridentitäten an +token=Zugangstoken. Kann durch das Hochladen des Zertifikates erhalten werden. +locale=Gebietsschema (Sprache) für die E-Mail-Verifikation +email=E-Mail-Adresse für die eine Verifikation angefragt werden soll +output.mails_sent=E-Mail-Verifikationen für Zertifikat %s wurden versendet.%n%n +output.token=Zugangstoken: %s%n +output.status=Status: +usage.synopsisHeading=Nutzung:\u0020 +usage.optionListHeading=Optionen:%n + +key-server=Adresse des verifizierenden Schlüsselservers.%nStandardmäßig: 'https://keys.openpgp.org' diff --git a/vks-java-cli/src/main/resources/msg_upload.properties b/vks-java-cli/src/main/resources/msg_upload.properties new file mode 100644 index 0000000..d2fa507 --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_upload.properties @@ -0,0 +1,8 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Upload an OpenPGP certificate to the key server +request-verification=Request verification mails for unpublished email addresses +output.uploaded_key=Uploaded key: %s%nToken: %s +output.status=Status: +key-server=Address of the Verifying Key Server.%nDefaults to 'https://keys.openpgp.org' diff --git a/vks-java-cli/src/main/resources/msg_upload_de.properties b/vks-java-cli/src/main/resources/msg_upload_de.properties new file mode 100644 index 0000000..cb38d3d --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_upload_de.properties @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Lade ein OpenPGP Zertifikat auf den Schlüsselserver hoch +request-verification=Fordere E-Mailverifikation für unveröffentlichte E-Mail-Adressen an +output.uploaded_key=Hochgeladenes Zertifikat: %s%nToken: %s +output.status=Status: +usage.synopsisHeading=Nutzung:\u0020 +usage.optionListHeading=Optionen:%n + +key-server=Adresse des verifizierenden Schlüsselservers.%nStandardmäßig: 'https://keys.openpgp.org' diff --git a/vks-java-cli/src/main/resources/msg_vks.properties b/vks-java-cli/src/main/resources/msg_vks.properties new file mode 100644 index 0000000..5ba0b01 --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_vks.properties @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Interact with Verifying Key Servers +usage.synopsisHeading=Usage:\u0020 +usage.commandListHeading=Commands:%n diff --git a/vks-java-cli/src/main/resources/msg_vks_de.properties b/vks-java-cli/src/main/resources/msg_vks_de.properties new file mode 100644 index 0000000..5b3099d --- /dev/null +++ b/vks-java-cli/src/main/resources/msg_vks_de.properties @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Interagiere mit verifizierenden Schlüsselservern +usage.synopsisHeading=Nutzung:\u0020 +usage.commandListHeading=Befehle:%n