-
Notifications
You must be signed in to change notification settings - Fork 157
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
Configuring multi-value defaults in list option in tz example #51
Comments
ah that’s nice - what happens if you mark such parameter arity="0..*" ...would it be possible to mix-match comma separated vs spaces or does that end up being a |
You don’t need to specify arity. |
not sure what I do wrong but I get an empty list on start, even tried upgrading to 4.2. the parameter parsing works though as it does work with but if just done as |
Can you push your code on a branch where I can take a look at it? |
#56 has the change - copied verbatim from your example + converter attribute (which does not seem to make a difference for this behavior). With that pr |
OK, I found the problem. The timezones option needs to be defined like this: @Parameters(index = "1..*", split = ",",
converter = ZoneIdConverter.class, // <.>
defaultValue = "America/Los_Angeles,America/Detroit,Europe/London,Europe/Zurich,Asia/Kolkata,Australia/Brisbane",
description = "Time zones. Defaults: ${DEFAULT-VALUE}.",
hideParamSyntax = true, paramLabel = "[<zones>[,<zones>...]...]")
List<ZoneId> zones; Note the Anyway, adding the index bit will fix it. One thing: I found this by switching on picocli's built-in debug tracing. I ended up changing the source code of the
and
In both cases, picocli is parsing the option and treats it as an application option: first of the jbang application, and next of the tz application. It may be worth treating |
thanks for the info, just pushed fixed to master and you gave me the idea to implement support for implementing |
Hi Max, congrats again on jbang, nice work!
The tz example mentions some difficulty with configuring defaults for multi-value options.
It is possible in picocli to configure default values for a multi-value option, if you are willing to allow comma-separated values. You would do that by setting the
split = ","
attribute in the@Option
or@Parameters
annotation. Then you can set multiple default values in a single string:Similarly for tz:
The text was updated successfully, but these errors were encountered: