-
Notifications
You must be signed in to change notification settings - Fork 424
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
Error message should show enum constant names, not toString() values, after value mismatch #592
Comments
I was able to reproduce the issue (thanks for providing all the details). By default, Picocli only recognizes enum values constant names. These are all uppercase in your program, so your program will accept You can tell Picocli to recognize enum values in a case-insensitive way, like this: CommandArgs command = new CommandArgs();
new CommandLine(command).setCaseInsensitiveEnumValuesAllowed(true).parseArgs(args); The error message from picocli is confusing. It should say:
I will improve this error message in the next release. Thanks for raising this issue! |
Thanks a lot |
I pushed a fix to master that improves the error message. Did the |
yes ,it 's solved |
Thanks for the confirmation! |
It seems the enum type can 't can be parsed correctly.
and my command is like this:
And i use it like this:
and when i use my app like this
and the error is shown
Exception in thread "main" picocli.CommandLine$ParameterException: Invalid value for option '--type': expected one of [word, excel, markdown] but was 'word'
at picocli.CommandLine$Interpreter.tryConvert(CommandLine.java:7485)
at picocli.CommandLine$Interpreter.applyValueToSingleValuedField(CommandLine.java:7145)
at picocli.CommandLine$Interpreter.applyOption(CommandLine.java:7082)
at picocli.CommandLine$Interpreter.processStandaloneOption(CommandLine.java:6974)
at picocli.CommandLine$Interpreter.processArguments(CommandLine.java:6883)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:6756)
at picocli.CommandLine$Interpreter.parse(CommandLine.java:6638)
at picocli.CommandLine.parse(CommandLine.java:727)
at picocli.CommandLine.populateCommand(CommandLine.java:680)
at com.dbdoc.App.main(App.java:37)
i can't see what 's the difference between these two 'word'.
So,is there something in my code?
The text was updated successfully, but these errors were encountered: