Add support for a mapper interface directly on fields.
If a field implements the MapperValue interface that interface will be used.
This commit is contained in:
@@ -70,8 +70,8 @@ func buildNode(k *Kong, v reflect.Value, typ NodeType, seenFlags map[string]bool
|
||||
name = strings.ToLower(dashedString(ft.Name))
|
||||
}
|
||||
|
||||
// Nested structs are either commands or args.
|
||||
if ft.Type.Kind() == reflect.Struct && (tag.Cmd || tag.Arg) {
|
||||
// Nested structs are either commands or args, unless they implement the Mapper interface.
|
||||
if ft.Type.Kind() == reflect.Struct && (tag.Cmd || tag.Arg) && k.registry.ForValue(fv) == nil {
|
||||
typ := CommandNode
|
||||
if tag.Arg {
|
||||
typ = ArgumentNode
|
||||
|
||||
Reference in New Issue
Block a user