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

v2 feature: Add optional check for duplicated string and int type flags. #1071

Open
arykalin opened this issue Feb 14, 2020 · 2 comments
Open

v2 feature: Add optional check for duplicated string and int type flags. #1071

arykalin opened this issue Feb 14, 2020 · 2 comments

Comments

@arykalin
Copy link

@arykalin arykalin commented Feb 14, 2020

Checklist

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

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:

flagFoo = &cli.StringFlag{
	Name: "foo",
	Duplicated: false,
}

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

@lynncyrin
Copy link
Member

@lynncyrin lynncyrin commented Feb 26, 2020

Sometimes users can accidently duplicate string type flags and then the latest value we be taken. It is not clear and bad for usability.

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"

@stale
Copy link

@stale stale bot commented May 26, 2020

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.

@stale stale bot added the status/stale label May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.