Skip to content

Commit

Permalink
Displays version properly when calling kafkactl without parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
twobeeb committed Jul 7, 2021
1 parent b195329 commit 6fc4451
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,6 +27,8 @@
public class KafkactlCommand implements Callable<Integer> {

public static boolean VERBOSE = false;
@Inject
public ConfigVersionProvider versionProvider;

@Option(names = {"-v", "--verbose"}, description = "...", scope = CommandLine.ScopeType.INHERIT)
public void setVerbose(final boolean verbose) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6fc4451

Please sign in to comment.