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
Add optional check for duplicated string and int type flags. #1071
Comments
Oh wow that sucks 😅we should definitely fix this 👍although possibly only in v3? Because I'm not sure if it would be considered a "breaking change" |
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else. |
Closing this as it has become stale. |
Will consider for v3 |
@arykalin If I understand correctly you've defined 2 flags(same type) with same name and only the last defined one will pick up values ? |
@arykalin Looking at your code you've defined "instance" as a stringslice flag and then enforced that if should not be length > 1 . Is this because if you've defined instance as a string flag and then people use the flag twice like --instance id1 and --instance id2 and then only the last value is taken. That is what you would like to guard against. ? |
Checklist
What problem does this solve?
Sometimes users can accidently duplicate string type flags and then the latest value we be taken. It is not clear and bad for usability.
Solution description
Add an option called Duplicated true\false to flag options. Example:
A detailed description of what you want to happen.
if Duplicated set to false command should fail with error
"flag foo can not be duplicated"
Describe alternatives you've considered
For now, as a workaround, we're using StringSliceType for flags we don't want to be duplicated and check that slice have only one element in it.
https://github.com/Venafi/vcert/blob/8e1dc13c0afdd615d7f27b80190ddf3a1d07e848/cmd/vcert/commands.go#L105-L120
The text was updated successfully, but these errors were encountered: