From 7de94f1815684a7f5f081af09daf3647994e5958 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Wed, 27 Jul 2022 14:30:48 +0200 Subject: [PATCH] Set resource bundle for help command --- .../src/main/java/sop/cli/picocli/SopCLI.java | 13 +++++++++---- sop-java-picocli/src/main/resources/help.properties | 4 ++++ .../src/main/resources/help_de.properties | 4 ++++ sop-java-picocli/src/main/resources/sop.properties | 2 -- .../src/main/resources/sop_de.properties | 2 -- 5 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 sop-java-picocli/src/main/resources/help.properties create mode 100644 sop-java-picocli/src/main/resources/help_de.properties diff --git a/sop-java-picocli/src/main/java/sop/cli/picocli/SopCLI.java b/sop-java-picocli/src/main/java/sop/cli/picocli/SopCLI.java index 2ce2e65..b823a8f 100644 --- a/sop-java-picocli/src/main/java/sop/cli/picocli/SopCLI.java +++ b/sop-java-picocli/src/main/java/sop/cli/picocli/SopCLI.java @@ -64,15 +64,20 @@ public class SopCLI { // Set locale new CommandLine(new InitLocale()).parseArgs(args); + // get error message bundle cliMsg = ResourceBundle.getBundle("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("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); diff --git a/sop-java-picocli/src/main/resources/help.properties b/sop-java-picocli/src/main/resources/help.properties new file mode 100644 index 0000000..518f793 --- /dev/null +++ b/sop-java-picocli/src/main/resources/help.properties @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Display usage information for the specified subcommand diff --git a/sop-java-picocli/src/main/resources/help_de.properties b/sop-java-picocli/src/main/resources/help_de.properties new file mode 100644 index 0000000..d933a4a --- /dev/null +++ b/sop-java-picocli/src/main/resources/help_de.properties @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: 2022 Paul Schaub +# +# SPDX-License-Identifier: Apache-2.0 +usage.header=Zeige Nutzungshilfen für den angegebenen Unterbefehl an diff --git a/sop-java-picocli/src/main/resources/sop.properties b/sop-java-picocli/src/main/resources/sop.properties index 3962861..4fd31a2 100644 --- a/sop-java-picocli/src/main/resources/sop.properties +++ b/sop-java-picocli/src/main/resources/sop.properties @@ -31,8 +31,6 @@ usage.exitCodeList.16=71:Unsupported special prefix (e.g. \"@env/@fd\") of indir usage.exitCodeList.17=73:Ambiguous input (a filename matching the designator already exists) usage.exitCodeList.18=79:Key is not signing capable -help.usage.header=Display usage information for the specified subcommand - ## SHARED RESOURCES ## Malformed Input sop.error.input.malformed_session_key=Session keys are expected in the format 'ALGONUM:HEXKEY'. diff --git a/sop-java-picocli/src/main/resources/sop_de.properties b/sop-java-picocli/src/main/resources/sop_de.properties index 78ccc39..d2542de 100644 --- a/sop-java-picocli/src/main/resources/sop_de.properties +++ b/sop-java-picocli/src/main/resources/sop_de.properties @@ -31,8 +31,6 @@ usage.exitCodeList.16=71:Nicht unterst usage.exitCodeList.17=73:Mehrdeutige Eingabe (ein Dateiname, der dem Bezeichner entspricht, existiert bereits) usage.exitCodeList.18=79:Schlüssel ist nicht fähig zu signieren -sop.help.usage.header=Zeige Nutzungshilfen für den angegebenen Unterbefehl an - ## SHARED RESOURCES ## Malformed Input sop.error.input.malformed_session_key=Nachrichtenschlüssel werden im folgenden Format erwartet: 'ALGONUM:HEXKEY'