Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
remkop opened this issue Feb 12, 2019 · 0 comments

Comments

@remkop
Copy link
Owner

remkop commented Feb 12, 2019

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.

@remkop remkop added this to the 3.9.4 milestone Feb 12, 2019
remkop added a commit that referenced this issue Feb 16, 2019
@remkop remkop changed the title Improve error message for invalid input "-a -b" (one arg) Improve error message for unknown options while processing clustered short options Feb 16, 2019
remkop added a commit that referenced this issue Feb 16, 2019
@remkop remkop closed this as completed Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant