feat: allow non-structs to be used as commands (#428)
* feat: allow non-structs to be used as commands This small MR allows using the func-to-interface trick to implement a command (see commandFunc in kong_test.go). This is useful e.g. for commands that have no flags or arguments of their own, but instead receive all required information via bound parameters. * fix: check DynamicCommand is runnable when adding
This commit is contained in:
@@ -51,6 +51,9 @@ type flattenedField struct {
|
||||
|
||||
func flattenedFields(v reflect.Value, ptag *Tag) (out []flattenedField, err error) {
|
||||
v = reflect.Indirect(v)
|
||||
if v.Kind() != reflect.Struct {
|
||||
return out, nil
|
||||
}
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
ft := v.Type().Field(i)
|
||||
fv := v.Field(i)
|
||||
|
||||
Reference in New Issue
Block a user