Support for flag prefixing.

This commit is contained in:
Alec Thomas
2018-09-12 12:17:57 +10:00
parent 844494faff
commit fd197e5081
5 changed files with 40 additions and 6 deletions
+4
View File
@@ -25,6 +25,8 @@ type Tag struct {
Hidden bool
Sep rune
Enum string
Group string
Prefix string // Optional prefix on anonymous structs. All sub-flags will have this prefix.
// Storage for all tag keys for arbitrary lookups.
items map[string]string
@@ -137,6 +139,8 @@ 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.Group = t.Get("group")
t.Prefix = t.Get("prefix")
if t.Sep == 0 {
if t.Get("sep") == "none" {
t.Sep = -1