-
Notifications
You must be signed in to change notification settings - Fork 8
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 option to treat array of string arguments as StringArray #55
Conversation
… CVS delimiter persing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me that we should make this optional, which would bifurcate programs using this framework. Some would handle array args in one way, and others would handle them in another way.
I think we need to figure out the long term direction here, weigh the pros and cons, and make a choice one way on the other 😬
@echlebek If we treat this is a deprecated behavior strategy a bifurcation is allowed for a period of time. |
@jspaleta I intend to pick up this PR and port it to rest on top of the more recent work I've been doing. |
This commit adds support to SlicePluginConfigOption for using cobra StringArray, when the type parameter is string. Other types of lists are not supported by cobra. The behaviour is enabled by setting the UseCobraStringArray field true. This option is useful when developers want to support lists of values, but want to consider values like "1,2" or "1 2" as a single value. This work is a take on #55, updated to reflect the recent changes to the plugin SDK. Signed-off-by: Eric Chlebek <[email protected]>
@jspaleta I had too much trouble porting the PR, so I just re-implemented it. Let me know if it makes sense to you. |
closing this one without merging as the new implementation solves the issue |
Closes #54
Implements an optional attribute Array, that if set changes how multiple call argument stringSlice are processed.
StringSlice -> automatic CSV comma delimited spliting of string value of each call of the argument
StringArray -> no automatic spliting of argument values, each argument call is taken as a separate array entry.
This is implemented as optional, because StringArray use requires more work when using with envvar to ensure you can split the envvar string using an delimiting string of your choice after arguments are parsed, but when strings need to have commas this gives you a way to deal with that.
gohandler_test.go updated with unit tests for both stringSlice and StringArray argument,envvar and annotation override handling.
Note we already have inconsistent handling of annotation overrides relative to argument and envvar handling for existing StringSlice Ref: #56.