-
Notifications
You must be signed in to change notification settings - Fork 425
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
Introduce a failing test for char[] type conversion #648
Conversation
Hi, What you're saying makes total sense. It has been on the todo list to improve this but other things took priority. As you pointed out, the type conversion logic in picocli is not easy, because it needs to support adding values to multi-value types like Map, Collection and arrays, as well as simply replacing values of single-value fields. However, I have some idea for adding support for password I am considering combining a fix for this with #536 to improve password handling overall and cutting a separate 3.9.x maintenance release for this. How urgent is this for you? I am currently working on #358, which is quite involved and will probably take some more time. I'd like to finish that and do a picocli-4.0-alpha-1 release before context-switching to the topic of passwords. |
@triceo Would you be okay with getting this in 4.0.0-alpha-2, or do you need a backport to the 3.9.x branch? I would prefer to spend as much time as possible on 4.0... |
@remkop That depends on how many incompatible changes there are in 4.0, and when that is coming out. Right now, I don't know anything about the release. |
So far it’s all backwards compatible. The final GA release is a few months away, but the alpha releases are high quality and pass all 1500+ unit tests. I’m releasing this functionality as alpha releases so that I have the option to change the API if peer review turns up any issues. |
@remkop Unfortunately, the release rules won't let me depend on a non-final artifact. That said, I understand your motivation for not putting this into a 3.9 - I'll wait for a final 4.0 then. |
Understood. Thanks for the clarification. I’ll try to do a separate 3.9.x release for these then. |
@triceo I’ve pushed some commits to the 3.X branch to improve support for interactive (password) options. I’ll create a 3.9.6 release for this soon, maybe later today. This includes the So, for “normal” (non-interactive) options, using a field of type It does make sense to go one step further and treat |
Hmm... |
Adding some ideas:
|
…port capturing multi-char values in char[] types for non-interactive options
I just took another look at this, but I'm not sure that I want to go ahead with this: The main goal (support for char[] types for interactive password options) has been achieved in 3.9.6. This ticket is still open because we are considering to go one step further and also allow normal (non-interactive) options to capture multi-char (String) values in a char[] type. On the face of it this would make things more consistent, but I hesitate to go ahead:
So I will probably postpone this remaining work until someone asks for this feature. Thoughts? |
@remkop It is true that, since 3.9.6, my use case is solved and I don't need anything more. If doing this feature in its entirety is too much for the existing system, feel free to postpone/ignore it. :-) |
Finally merged! 😅 |
When I have a
char[]
-typed@Option
in my command-line object, I get an error when trying to set it from the command line:It appears that Picocli treats
char[]
aschar
. The expected behavior instead would be that the inputString
is converted tochar[]
using itstoCharArray()
method.Couple more notes:
char[]
as the data type is a pretty common thing when the parameter is a password. The array can be manually zeroed when the password is no longer needed, thus completely removing it from memory while its parent object still lives.String
for the same purpose is sub-optimal, as JVM does all kinds of magic withStrings
and the password could, for example, be interned - irrevocably burning it into the JVM memory for the entire runtime of the application.