diff --git a/flags.go b/flags.go index 23826bf..16494a7 100644 --- a/flags.go +++ b/flags.go @@ -41,13 +41,13 @@ func (f *flagGroup) init() error { func (f *flagGroup) parse(tokens tokens, ignoreRequired bool) (tokens, error) { // Track how many required flags we've seen. - required := make(map[string]struct{}) + required := make(map[string]bool) // Keep track of any flags that we need to initialise with defaults. - defaults := make(map[string]struct{}) + defaults := make(map[string]bool) for k, flag := range f.long { - defaults[k] = struct{}{} + defaults[k] = true if !ignoreRequired && flag.needsValue() { - required[k] = struct{}{} + required[k] = true } } diff --git a/parsers.go b/parsers.go index 394b58c..a22db76 100644 --- a/parsers.go +++ b/parsers.go @@ -264,11 +264,11 @@ func (p *parserMixin) URLListVar(target *[]*url.URL) { // Enum allows a value from a set of options. func (p *parserMixin) Enum(options ...string) (target *string) { target = new(string) - p.EnumVar(target, options...) + p.EnumVar(&target, options...) return } // EnumVar allows a value from a set of options. -func (p *parserMixin) EnumVar(target *string, options ...string) { +func (p *parserMixin) EnumVar(target **string, options ...string) { p.SetValue(newEnumFlag(target, options...)) } diff --git a/values.go b/values.go index 16cb4e7..989dc1d 100644 --- a/values.go +++ b/values.go @@ -420,16 +420,15 @@ type enumValue struct { options []string } -func newEnumFlag(target *string, options ...string) *enumValue { - value := new(string) +func newEnumFlag(target **string, options ...string) *enumValue { return &enumValue{ - value: value, + value: *target, options: options, } } func (a *enumValue) String() string { - return *a.value + " [" + strings.Join(a.options, "|") + "]" + return *a.value } func (a *enumValue) Set(value string) error {