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

Add StringMap flag #1580

Closed
3 tasks done
avorima opened this issue Nov 9, 2022 · 7 comments · Fixed by #1590
Closed
3 tasks done

Add StringMap flag #1580

avorima opened this issue Nov 9, 2022 · 7 comments · Fixed by #1590
Labels
area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this

Comments

@avorima
Copy link
Contributor

avorima commented Nov 9, 2022

Checklist

  • Are you running the latest v2 release? The list of releases is here.
  • Did you check the manual for your release? The v2 manual is here.
  • Did you perform a search about this feature? Here's the GitHub guide about searching.

What problem does this solve?

There is no string mapping flag so I usually end up using a string slice and then splitting the elements into key/value pairs. pflag has the option to use the StringToString flag: https://github.com/spf13/pflag/blob/master/string_to_string.go.

Solution description

Add a StringMapFlag and StringMap type that can be used like StringSlice/Flag, but is backed by a map[string]string and splits the elements accordingly with validation. Separator could be configurable, but I think = is a common default.

Describe alternatives you've considered

Create a custom flag, but that would be even more boilerplate than now.

@avorima avorima added area/v2 relates to / is being considered for v2 status/triage maintainers still need to look into this labels Nov 9, 2022
@dearchap dearchap added area/v3 relates to / is being considered for v3 and removed area/v2 relates to / is being considered for v2 labels Nov 9, 2022
@dearchap
Copy link
Contributor

dearchap commented Nov 9, 2022

@avorima We are not adding any new features to v2. Would you like to submit a PR for this for v3 ?

@avorima
Copy link
Contributor Author

avorima commented Nov 9, 2022

Yeah, I can give it a shot. So do I use main or v3-dev-main as base? Looking at https://cli.urfave.org/CONTRIBUTING/ I guess it should be v3-dev-main, but I see that main already has v3 in its go.mod

@dearchap
Copy link
Contributor

dearchap commented Nov 9, 2022

yes please use main.

@artemklevtsov
Copy link

Will there be support for altsrc?

@dearchap
Copy link
Contributor

@artemklevtsov would you like to submit a PR for altsrc ?

@artemklevtsov
Copy link

Hm... I'll digging into it.

@dearchap
Copy link
Contributor

@artemklevtsov Lets continue this conversation in issue #1634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/v3 relates to / is being considered for v3 status/triage maintainers still need to look into this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants