jcommander icon indicating copy to clipboard operation
jcommander copied to clipboard

Commands with no description have the string "null" printed as their description when calling usage()

Open jkosh44 opened this issue 5 years ago • 1 comments

Steps to reproduce:

public class DescriptionIssue {
  static class Command {
    @Parameter(names = "-t")
    private String test;
  }

  public static void main(String[] args) {
    JCommander jCommander = JCommander.newBuilder().addCommand("testCommand", new Command()).build();
    jCommander.usage();
  }
}

The jCommander.usage() call above will result in the String literal "null" being printed instead of any description. Below I have copied the result of running that main method:

Usage: <main class> [command] [command options]
  Commands:
    testCommand      null
      Usage: testCommand [options]
        Options:
          -t

Instead of printing "null" it should either print nothing as the description or raise an error that the command doesn't have a description

jkosh44 avatar Dec 12 '19 04:12 jkosh44

By the way, I'm using version 1.78 for this.

jkosh44 avatar Dec 17 '19 03:12 jkosh44