diff --git a/_examples/server/main.go b/_examples/server/main.go index f681a25..61b1010 100644 --- a/_examples/server/main.go +++ b/_examples/server/main.go @@ -8,12 +8,11 @@ import ( "os" "strings" - "golang.org/x/crypto/ssh/terminal" - "github.com/chzyer/readline" "github.com/gliderlabs/ssh" "github.com/google/shlex" "github.com/kr/pty" + "golang.org/x/crypto/ssh/terminal" "github.com/alecthomas/colour" "github.com/alecthomas/kong" diff --git a/model.go b/model.go index 2974c91..38f1d0d 100644 --- a/model.go +++ b/model.go @@ -253,10 +253,11 @@ func (v *Value) IsBool() bool { // Parse tokens into value, parse, and validate, but do not write to the field. func (v *Value) Parse(scan *Scanner, target reflect.Value) error { err := v.Mapper.Decode(&DecodeContext{Value: v, Scan: scan}, target) - if err == nil { - v.Set = true + if err != nil { + return fmt.Errorf("%s: %s", v.Summary(), err) } - return err + v.Set = true + return nil } // Apply value to field.