Validate after everything is applied.

Fixes #27.
This commit is contained in:
Alec Thomas
2019-06-21 12:09:04 +10:00
parent 95de7d2f0d
commit 102a975844
4 changed files with 20 additions and 8 deletions
+2 -2
View File
@@ -209,10 +209,10 @@ func (k *Kong) Parse(args []string) (ctx *Context, err error) {
if err = k.applyHook(ctx, "BeforeApply"); err != nil {
return nil, &ParseError{error: err, Context: ctx}
}
if err = ctx.Validate(); err != nil {
if _, err = ctx.Apply(); err != nil {
return nil, &ParseError{error: err, Context: ctx}
}
if _, err = ctx.Apply(); err != nil {
if err = ctx.Validate(); err != nil {
return nil, &ParseError{error: err, Context: ctx}
}
if err = k.applyHook(ctx, "AfterApply"); err != nil {