projectdiscovery / goflags

A go flag wrapper with convenience helpers
MIT License
84 stars 16 forks source link

EnumSlice Type Flag: support multi enum #127

Closed dogancanbakir closed 1 year ago

dogancanbakir commented 1 year ago

Proposal

type VariableType uint8
const (
    Type1 VariableType = iota
    Type2
)
allowedTypes := map[string]VariableType{"type1": Type1, "type2": Type2} 
flagSet.EnumSliceVar(&options.Type, "type", "", "Variable Type (type1/type2)", allowedTypes}),
go run . -type type1 # ok
go run . -type type2 # ok
go run . -type type1,type2 # ok
go run . -type type3 # error