diff --git a/build.go b/build.go index b3299cc..43e4b6c 100644 --- a/build.go +++ b/build.go @@ -118,6 +118,7 @@ func buildNode(v reflect.Value, seenFlags map[string]bool, cmd bool) *Node { Help: tag.Help, Default: tag.Default, Decoder: decoder, + Tag: tag, Value: fv, // Flags are optional by default, and args are required by default. diff --git a/decoders.go b/decoders.go index f477417..2858889 100644 --- a/decoders.go +++ b/decoders.go @@ -222,7 +222,7 @@ func floatDecoder(bits int) DecoderFunc { func sliceDecoder(ctx *DecoderContext, scan *Scanner, target reflect.Value) error { el := target.Type().Elem() - sep, ok := ctx.Value.Tag.Lookup("sep") + sep, ok := ctx.Value.Tag.Get("sep") if !ok { sep = "," } diff --git a/model.go b/model.go index 388f6d7..32fb206 100644 --- a/model.go +++ b/model.go @@ -30,7 +30,7 @@ type Value struct { Help string Default string Decoder Decoder - Tag reflect.StructTag + Tag *Tag Value reflect.Value Required bool Set bool // Used with Required to test if a value has been given. diff --git a/tag.go b/tag.go index 46e1667..5431783 100644 --- a/tag.go +++ b/tag.go @@ -123,8 +123,9 @@ func (t *Tag) Has(k string) bool { return ok } -func (t *Tag) Get(k string) (string, error) { - return t.items[k], nil +func (t *Tag) Get(k string) (string, bool) { + s, ok := t.items[k] + return s, ok } func (t *Tag) GetBool(k string) (bool, error) {