Use new Tag type for slice separator.
This commit is contained in:
@@ -118,6 +118,7 @@ func buildNode(v reflect.Value, seenFlags map[string]bool, cmd bool) *Node {
|
|||||||
Help: tag.Help,
|
Help: tag.Help,
|
||||||
Default: tag.Default,
|
Default: tag.Default,
|
||||||
Decoder: decoder,
|
Decoder: decoder,
|
||||||
|
Tag: tag,
|
||||||
Value: fv,
|
Value: fv,
|
||||||
|
|
||||||
// Flags are optional by default, and args are required by default.
|
// Flags are optional by default, and args are required by default.
|
||||||
|
|||||||
+1
-1
@@ -222,7 +222,7 @@ func floatDecoder(bits int) DecoderFunc {
|
|||||||
|
|
||||||
func sliceDecoder(ctx *DecoderContext, scan *Scanner, target reflect.Value) error {
|
func sliceDecoder(ctx *DecoderContext, scan *Scanner, target reflect.Value) error {
|
||||||
el := target.Type().Elem()
|
el := target.Type().Elem()
|
||||||
sep, ok := ctx.Value.Tag.Lookup("sep")
|
sep, ok := ctx.Value.Tag.Get("sep")
|
||||||
if !ok {
|
if !ok {
|
||||||
sep = ","
|
sep = ","
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type Value struct {
|
|||||||
Help string
|
Help string
|
||||||
Default string
|
Default string
|
||||||
Decoder Decoder
|
Decoder Decoder
|
||||||
Tag reflect.StructTag
|
Tag *Tag
|
||||||
Value reflect.Value
|
Value reflect.Value
|
||||||
Required bool
|
Required bool
|
||||||
Set bool // Used with Required to test if a value has been given.
|
Set bool // Used with Required to test if a value has been given.
|
||||||
|
|||||||
@@ -123,8 +123,9 @@ func (t *Tag) Has(k string) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tag) Get(k string) (string, error) {
|
func (t *Tag) Get(k string) (string, bool) {
|
||||||
return t.items[k], nil
|
s, ok := t.items[k]
|
||||||
|
return s, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tag) GetBool(k string) (bool, error) {
|
func (t *Tag) GetBool(k string) (bool, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user