-
Notifications
You must be signed in to change notification settings - Fork 333
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
Password option behaviour is unintuitive and inflexible #70
Comments
Not sure I follow:
Overall, your proposal is reasonable and I should probably have done that in the first place, but it overlaps with what JCommander is currently doing so I think it might introduce some confusion, unless I completely remove the password attribute to @parameter, which is not really feasible since it would break backward compatibility. |
I thought about compatibility. It's true that you'll have to keep backwards compatibility in terms of API usage and behaviour. For this reason, my proposal simply adds on top, and therefore users of the old API will have the same behaviour. I understand that having two APIs for doing the same thing is not very elegant, but there is always an option to mark the old API deprecated. Let me know what you think. |
The following I find unintuitive and inflexible:
@passwd.txt
would be nice.required=true
set, then the user is forced to pass the--pass
argument just to get a password prompt on the screen. If the password is required there should be no need to specify--pass
on the command line.In fact, number 2. applies to all boolean options with
required=true
set. It does not really make sense to have required boolean options, unless the user can do something like--debug=false
Back to the point, I'd like to propose an interface like this:
@PasswordParameter
.@PasswordParameter(names = {"-p", "--pass"})
behaves like a standardString
option (i.e. has arity of 1).@PasswordParameter(flags = {"--prompt"})
behaves like the current implementation (i.e. has arity of 0).-p=secret
would get the password from cmd, and--prompt
would ask for password in the console. If no options specified not password is set and the program proceeds as usual.The
@PasswordParameter
annotation will have all the same fields as in standard@Parameter
, exceptpassword
and with an additionalString[] flags() default {}
.The text was updated successfully, but these errors were encountered: