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 enum flag type #80

Merged
merged 2 commits into from
Sep 30, 2022
Merged

Add enum flag type #80

merged 2 commits into from
Sep 30, 2022

Conversation

parrasajad
Copy link
Contributor

@parrasajad parrasajad commented Sep 26, 2022

Example:

const (
	Nil goflags.EnumVariable = iota
	Type1
	Type2
)
allowedTypes := goflags.AllowdTypes{"type1": Type1, "type2": Type2}

flagSet.EnumVarP(&options.Type, "enum-type", "et", Nil, "Variable Type (type1/type2)", allowedTypes)

output:

$go run . --type type3
invalid value "type3" for flag -type: allowed values are type1, type2

$go run . --type type1 //ok

@parrasajad parrasajad linked an issue Sep 26, 2022 that may be closed by this pull request
Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - Remaining todos:

  • Tests (both positive and negative)
  • Update docs

@Mzack9999 Mzack9999 added the Type: Enhancement Most issues will probably ask for additions or changes. label Sep 30, 2022
@ehsandeep ehsandeep merged commit fc213f8 into dev Sep 30, 2022
@ehsandeep ehsandeep deleted the enum-var branch September 30, 2022 15:41
@ehsandeep ehsandeep removed a link to an issue Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants