Skip to content
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

Support slice flag inputs with commas #45

Open
integrii opened this issue May 23, 2019 · 3 comments
Open

Support slice flag inputs with commas #45

integrii opened this issue May 23, 2019 · 3 comments
Assignees
Labels
proposal Proposed changes to flaggy

Comments

@integrii
Copy link
Owner

Currently, slice flags are required to be specified multiple times. It could be helpful though to automatically parse commas in slice flag inputs into different values. Then again, it could make passing literal commas more confusing.

Should we support slice inputs like this:
./app -str one,two
which results in []string{"one","two"}

or should we continue to only support multiple flag uses like this:
./app -str one -str two
which results in the same [string{"one","two"}

@integrii integrii added the proposal Proposed changes to flaggy label May 23, 2019
@integrii integrii self-assigned this May 23, 2019
@integrii
Copy link
Owner Author

The StringSlice flag was already modified to split on commas, but we may want to revert that if we want commas to remain literals as originally designed: b5bd289

@integrii
Copy link
Owner Author

I think we could keep the default comma parsing behavior here while adding a new string slice flag type that takes commas directly without considering them a character to split input on.

@jdevera
Copy link

jdevera commented Jun 5, 2022

An alternative could be what the stdlib flag does, which is to define a Value interface with a Set(string) error method that anybody can implement on their own types. That brings the possibility of projects such as https://pkg.go.dev/github.com/sgreben/flagvar to create Values for different use cases and the library does not need to support them all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposed changes to flaggy
Projects
None yet
Development

No branches or pull requests

2 participants