add support to make map separator configurable

This commit is contained in:
Rene Zbinden
2020-02-14 10:47:58 +01:00
committed by Alec Thomas
parent ca3a30c5f1
commit 529703d8d1
4 changed files with 23 additions and 2 deletions
+9
View File
@@ -25,6 +25,7 @@ type Tag struct {
Short rune
Hidden bool
Sep rune
MapSep rune
Enum string
Group string
Xor string
@@ -151,6 +152,7 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag {
t.Hidden = t.Has("hidden")
t.Format = t.Get("format")
t.Sep, _ = t.GetRune("sep")
t.MapSep, _ = t.GetRune("mapsep")
t.Group = t.Get("group")
t.Xor = t.Get("xor")
t.Prefix = t.Get("prefix")
@@ -162,6 +164,13 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag {
t.Sep = ','
}
}
if t.MapSep == 0 {
if t.Get("mapsep") == "none" {
t.MapSep = -1
} else {
t.MapSep = ';'
}
}
t.Vars = Vars{}
for _, set := range t.GetAll("set") {
parts := strings.SplitN(set, "=", 2)