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

Feature Request: Add ability to specify delimiter for slice flags #245

Open
pcman312 opened this issue Sep 13, 2017 · 1 comment · May be fixed by #419
Open

Feature Request: Add ability to specify delimiter for slice flags #245

pcman312 opened this issue Sep 13, 2017 · 1 comment · May be fixed by #419

Comments

@pcman312
Copy link

pcman312 commented Sep 13, 2017

When specifying a slice flag:

Strs []string `short:"s" long:"strs" description:"..."

there doesn't appear to be a way to specify a delimiter to use to split the provided strings into the string slice. For instance, if the above flag is specified:

./program -s one,two -s three

Results in:

0: one,two
1: three

Instead of:

0: one
1: two
2: three

The typical way to do this is to specify -s multiple times. Adding the ability to split the arguments by a delimiter would be a big usability improvement, particularly when you need to specify many arguments into that slice.

There currently is the env-delim option which appears to have a similar functionality. I propose to add a delim option that will split the flag values by the given delimiter.

pazderak pushed a commit to pazderak/go-flags that referenced this issue Oct 19, 2017
pazderak pushed a commit to pazderak/go-flags that referenced this issue Dec 9, 2017
@oguzyildizz
Copy link

Also, I would personally add a size tag that would enforce slice (or maybe additionally, string size) arguments. Could be a range or a single integer.
e.g.
size:"3"
size:"1,-"
size:"-,4"
size"3,5"

@Lun4m Lun4m linked a pull request Nov 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants