cbeust / jcommander

Command line parsing framework for Java
Apache License 2.0
1.96k stars 334 forks source link

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

Closed jkosh44 closed 1 year ago

jkosh44 commented 4 years ago

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 commented 4 years ago

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