From 6fc445187389658675da995ec41b7ecfae7b1b7d Mon Sep 17 00:00:00 2001 From: twobeeb Date: Wed, 7 Jul 2021 17:42:36 +0200 Subject: [PATCH] Displays version properly when calling kafkactl without parameters --- .../java/com/michelin/ns4kafka/cli/KafkactlCommand.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java b/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java index 1e010adb..168ff806 100644 --- a/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java +++ b/cli/src/main/java/com/michelin/ns4kafka/cli/KafkactlCommand.java @@ -6,6 +6,7 @@ import picocli.CommandLine.Option; import javax.inject.Inject; +import javax.inject.Singleton; import java.util.Optional; import java.util.concurrent.Callable; @@ -26,6 +27,8 @@ public class KafkactlCommand implements Callable { public static boolean VERBOSE = false; + @Inject + public ConfigVersionProvider versionProvider; @Option(names = {"-v", "--verbose"}, description = "...", scope = CommandLine.ScopeType.INHERIT) public void setVerbose(final boolean verbose) { @@ -56,13 +59,14 @@ public static void main(String[] args) throws Exception { public Integer call() throws Exception { CommandLine cmd = new CommandLine(new KafkactlCommand()); // Display help - cmd.printVersionHelp(System.out); + System.out.println(versionProvider.getVersion()[0]); cmd.usage(System.out); return 0; } + @Singleton public static class ConfigVersionProvider implements CommandLine.IVersionProvider { @Inject