Skip to content

programmatic command registration: option name needs to match parameter name #1042

Open
@georgmittendorfer

Description

@georgmittendorfer

Current behaviour:

Currently the following registration (assuming there is some pojo named command)

CommandRegistration.builder()
                .command("some-command")
                .withTarget().method(command, "add").and()
                .withOption().longNames("identity").and()
                .build();

matches the method

public String add(String identity) { ... }

but it would not match the method

public String add(String id) { ... }

That means that the option name needs to be equal to the parameter name but there is no reason for this as it is the only parameter. That is not very intuitive and it is not documented anywhere (at least I didn't find it).

Expected behaviour:

  • When target method only has one parameter it should match independent of the option name.
  • When target method only has one parameter it should even match given input without option name or there should be an error message that the option is missing (currently it simply passes null even if the option is required).
  • It should be documented somewhere what the requirements for option matching are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions