Skip to content

Improve error message for unknown options while processing clustered short options #627

@remkop

Description

@remkop

How to reproduce:

class App {
    @Option(names = "-a", groups = "ALL") boolean a;
    @Option(names = "-b", groups = "ALL") boolean b;
}

CommandLine.populate(new Args(), "-a -b"); // NOT "-a", "-b" !

Gives this cryptic error message:

UnmatchedArgumentException: Unknown option: - -b

The parser takes this as a POSIX clustered option group, matches the "-a" part, then tries and fails to match the remainder " -b" (with leading space) by prefixing with a - and going through the logic in processClusteredShortOptions again. This results in the surprising error message.

One option to improve this is to add the original option cluster in the error message.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions