Skip to content

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

@arykalin

Description

@arykalin

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

Metadata

Metadata

Assignees

Labels

area/v3relates to / is being considered for v3help wantedplease help if you can!status/claimedsomeone has claimed this issuestatus/confirmedconfirmed to be valid, but work has yet to start

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions