-
Notifications
You must be signed in to change notification settings - Fork 434
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
Invalid value for option '--xyz': '' is not an int #626
Comments
Actually, what happens during a call to
So, if the option is not specified on the command line, it should get the default value. I’m surprised you are getting When the option is specified without a value, it is assigned an empty string. You can use a custom type converter for that option to convert this empty string to the desired value. See also the discussion in #280 about adding some API to make this more convenient. |
Regarding: "When the option is specified without a value, it is assigned an empty string." |
The idea (see #279 and #280 for background) is that some applications want to distinguish between the option not being specified at all, and the option being specified without a value. In the latter case, picocli assigns an empty string. This is documented in the user manual: https://picocli.info/#_optional_values With the current version of picocli, you need to specify a custom converter to replace the empty string with some legal value. This is not the most convenient way, so we’re looking for a better alternative in #280. By the way, were you able to verify that the default value is assigned when the option isn’t specified altogether? |
By the way, any feedback, comments or suggestions related to syntax on #280 are welcome! |
I just checked again, you are right, when I don't specify the option, the default value is applied. I must have mixed this up during all the testing. I am closing this in favor of #280 |
For the following code:
I would expect:
Invalid value for option '--duration': '' is not an int
The text was updated successfully, but these errors were encountered: