Display usage information on error.
This commit is contained in:
@@ -23,6 +23,7 @@ type Tag struct {
|
||||
Short rune
|
||||
Hidden bool
|
||||
Sep rune
|
||||
Enum map[string]bool
|
||||
|
||||
// Storage for all tag keys for arbitrary lookups.
|
||||
items map[string]string
|
||||
@@ -112,6 +113,7 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag {
|
||||
s, chars := getTagInfo(ft)
|
||||
t := &Tag{
|
||||
items: parseTagItems(s, chars),
|
||||
Enum: map[string]bool{},
|
||||
}
|
||||
t.Cmd = t.Has("cmd")
|
||||
t.Arg = t.Has("arg")
|
||||
@@ -141,6 +143,9 @@ func parseTag(fv reflect.Value, ft reflect.StructField) *Tag {
|
||||
if t.PlaceHolder == "" {
|
||||
t.PlaceHolder = strings.ToUpper(dashedString(fv.Type().Name()))
|
||||
}
|
||||
for _, part := range strings.Split(t.Get("enum"), ",") {
|
||||
t.Enum[part] = true
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user