]> Cypherpunks repositories - gostls13.git/commitdiff
flag: Describe the ErrorHandling enum values.
authorAaron Jacobs <jacobsa@google.com>
Fri, 5 Jun 2015 00:12:34 +0000 (10:12 +1000)
committerRob Pike <r@golang.org>
Fri, 5 Jun 2015 13:53:26 +0000 (13:53 +0000)
ContinueOnError is particularly confusing, because it causes
FlagSet.Parse to return as soon as it sees an error. I gather that the
intent is "continue the program" rather than "continue parsing",
compared to exiting or panicking.

Change-Id: I27370ce1f321ea4debcee5b03faff3532495c71a
Reviewed-on: https://go-review.googlesource.com/10740
Reviewed-by: Rob Pike <r@golang.org>
src/flag/flag.go

index 060660248efe3916f98fabf05740c089a55d93f6..d1cb0a5ae6bb091639d240fbd085fc6f06a554b2 100644 (file)
@@ -249,13 +249,14 @@ type Getter interface {
        Get() interface{}
 }
 
-// ErrorHandling defines how to handle flag parsing errors.
+// ErrorHandling defines how FlagSet.Parse behaves if the parse fails.
 type ErrorHandling int
 
+// These constants cause FlagSet.Parse to behave as described if the parse fails.
 const (
-       ContinueOnError ErrorHandling = iota
-       ExitOnError
-       PanicOnError
+       ContinueOnError ErrorHandling = iota // Return a descriptive error.
+       ExitOnError                          // Call os.Exit(2).
+       PanicOnError                         // Call panic with a descriptive error.
 )
 
 // A FlagSet represents a set of defined flags.  The zero value of a FlagSet