change help hook and call Reset later

change to BeforeResolve hook to catch calls to '--help' earlier;
call reset later in Kong.Parse() to allow help hook to get hooked;
add test;
This commit is contained in:
pyq-lsa
2022-05-01 13:17:44 -07:00
committed by Alec Thomas
parent 7c6ff10d33
commit 5538b7f045
4 changed files with 24 additions and 5 deletions
+1 -1
View File
@@ -248,7 +248,7 @@ func main() {
If a node in the grammar has a `BeforeResolve(...)`, `BeforeApply(...) error` and/or `AfterApply(...) error` method, those methods will be called before validation/assignment and after validation/assignment, respectively.
The `--help` flag is implemented with a `BeforeApply` hook.
The `--help` flag is implemented with a `BeforeResolve` hook.
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()`.