Skip to content

Help text mismatched between commands with identical Java parameter signatures #131

Description

@dblevins

When two @Command-annotated methods in the same class have identical Java parameter signatures, help displays the wrong description for the later method — it inherits the description from the first method with the same signature.

The annotation processor correctly extracts and stores each method's javadoc separately in META-INF/crest/<class>/<name>.<index>.properties. Each file has the correct content. The bug appears at runtime, in the matching of a command name to its help-properties file.

Reproduction

package com.example;

import org.tomitribe.crest.api.Command;

public class Commands {

    /**
     * Add a Date field.
     */
    @Command("date add")
    public String addDate(final String objectName, final String fieldLabel) {
        return "date";
    }

    /**
     * Add an Email field.
     */
    @Command("email add")
    public String addEmail(final String objectName, final String fieldLabel) {
        return "email";
    }
}

Run <your-main> help --all.

Expected

   date add    Add a Date field.
   email add   Add an Email field.

Actual

   date add    Add a Date field.
   email add   Add a Date field.    <- wrong

Pattern

The same effect occurs across any group of methods sharing parameter types. In one of our codebases, a FieldCommand class has 14 @Command("<type> add") methods. Three groups share signatures:

  • (String, String, SharedOptions, Config) — used by date, datetime, email, phone, url. All five render with date's description.
  • (String, String, int, int, SharedOptions, Config) — used by number, currency, percent, textarea. All four render with number's description, even though the two int parameters mean different things across these methods (precision/scale vs length/visibleLines). The @Option names differ but the Java types are identical.

The @Option names that would disambiguate are not part of the matching key.

Workaround

Setting description on the @Command annotation directly bypasses the javadoc-first-sentence pickup and renders correctly:

@Command(value = "email add", description = "Add an Email field.")

Possible fix

Include the @Command value in the match key, not only the Java parameter signature.

Environment

  • Crest: 0.45
  • JDK: 17 (project compiled with <source>11</source> <target>11</target>)
  • OS: macOS Darwin 25.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions