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:
Leo Antunes
2024-07-05 14:51:38 +02:00
committed by GitHub
parent 605cdd64a9
commit e864bb0220
4 changed files with 25 additions and 2 deletions
+1 -1
View File
@@ -903,7 +903,7 @@ func checkMissingChildren(node *Node) error {
if len(missing) == 1 {
return fmt.Errorf("expected %s", missing[0])
}
return fmt.Errorf("expected one of %s", strings.Join(missing, ", "))
return fmt.Errorf("expected one of %s", strings.Join(missing, ", "))
}
// If we're missing any positionals and they're required, return an error.