aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorSteven Roose <[email protected]>2017-10-20 13:06:17 +0200
committerAlbert Nigmatzianov <[email protected]>2017-10-20 13:06:17 +0200
commit97afa5e7ca8a08a383cb259e06636b5e2cc7897f (patch)
tree6b17fe97f4bd89a8ddeb415c6012893d6656465e /flag.go
parent1f33b80956cde38911d1f23d764deb8d77a649ce (diff)
Prevent printing when using ContinueOnError (#144)
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/flag.go b/flag.go
index 187e4c9..73c237b 100644
--- a/flag.go
+++ b/flag.go
@@ -873,8 +873,10 @@ func VarP(value Value, name, shorthand, usage string) {
// returns the error.
func (f *FlagSet) failf(format string, a ...interface{}) error {
err := fmt.Errorf(format, a...)
- fmt.Fprintln(f.out(), err)
- f.usage()
+ if f.errorHandling != ContinueOnError {
+ fmt.Fprintln(f.out(), err)
+ f.usage()
+ }
return err
}
@@ -1056,6 +1058,7 @@ func (f *FlagSet) Parse(arguments []string) error {
case ContinueOnError:
return err
case ExitOnError:
+ fmt.Println(err)
os.Exit(2)
case PanicOnError:
panic(err)