fix: don't require a Run() method on dynamic commands
Commands can be dispatched via string, so this is not necessary to constitute a command.
This commit is contained in:
@@ -99,10 +99,6 @@ type dynamicCommand struct {
|
|||||||
// "tags" is a list of extra tag strings to parse, in the form <key>:"<value>".
|
// "tags" is a list of extra tag strings to parse, in the form <key>:"<value>".
|
||||||
func DynamicCommand(name, help, group string, cmd any, tags ...string) Option {
|
func DynamicCommand(name, help, group string, cmd any, tags ...string) Option {
|
||||||
return OptionFunc(func(k *Kong) error {
|
return OptionFunc(func(k *Kong) error {
|
||||||
if run := getMethod(reflect.Indirect(reflect.ValueOf(cmd)), "Run"); !run.IsValid() {
|
|
||||||
return fmt.Errorf("kong: DynamicCommand %q must be a type with a 'Run' method; got %T", name, cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
k.dynamicCommands = append(k.dynamicCommands, &dynamicCommand{
|
k.dynamicCommands = append(k.dynamicCommands, &dynamicCommand{
|
||||||
name: name,
|
name: name,
|
||||||
help: help,
|
help: help,
|
||||||
|
|||||||
Reference in New Issue
Block a user