You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-4
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,8 @@
13
13
-[Command handling](#command-handling)
14
14
-[Switch on the command string](#switch-on-the-command-string)
15
15
-[Attach a `Run(...) error` method to each command](#attach-a-run-error-method-to-each-command)
16
-
-[Hooks: BeforeReset(), BeforeResolve(), BeforeApply(), AfterApply() and the Bind() option](#hooks-beforereset-beforeresolve-beforeapply-afterapply-and-the-bind-option)
If a node in the CLI, or any of its embedded fields, has a `BeforeReset(...) error`, `BeforeResolve
311
312
(...) error`, `BeforeApply(...) error` and/or `AfterApply(...) error` method, those
@@ -314,8 +315,6 @@ and after validation/assignment, respectively.
314
315
315
316
The `--help` flag is implemented with a `BeforeReset` hook.
316
317
317
-
Arguments to hooks are provided via the `Run(...)` method or `Bind(...)` option. `*Kong`, `*Context` and `*Path` are also bound and finally, hooks can also contribute bindings via `kong.Context.Bind()` and `kong.Context.BindTo()`.
318
-
319
318
eg.
320
319
321
320
```go
@@ -341,6 +340,40 @@ func main() {
341
340
}
342
341
```
343
342
343
+
## The Bind() option
344
+
345
+
Arguments to hooks are provided via the `Run(...)` method or `Bind(...)` option. `*Kong`, `*Context`, `*Path` and parent commands are also bound and finally, hooks can also contribute bindings via `kong.Context.Bind()` and `kong.Context.BindTo()`.
Any [mapped](#mapper---customising-how-the-command-line-is-mapped-to-go-values) field in the command structure _not_ tagged with `cmd` or `arg` will be a flag. Flags are optional by default.
0 commit comments