aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Porter <[email protected]>2017-09-30 17:16:53 -0400
committerAlbert Nigmatzianov <[email protected]>2017-09-30 23:16:53 +0200
commit5c2d607c75df0540c877524f9e82d3edb7748668 (patch)
tree407cff68662199c007da5e4aeb6a7786e5b5c2e4
parent7aff26db30c1be810f9de5038ec5ef96ac41fd7c (diff)
Generate flag error output for errors returned from the parseFunc (#138)
-rw-r--r--flag.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/flag.go b/flag.go
index 7b84e2c..85c34a7 100644
--- a/flag.go
+++ b/flag.go
@@ -916,6 +916,9 @@ func (f *FlagSet) parseLongArg(s string, args []string, fn parseFunc) (a []strin
}
err = fn(flag, value)
+ if err != nil {
+ f.failf(err.Error())
+ }
return
}
@@ -966,6 +969,9 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse
}
err = fn(flag, value)
+ if err != nil {
+ f.failf(err.Error())
+ }
return
}