Add support for custom boolean flags through IsBoolFlag()

This is consistent with Go's native flag parsing module and can be used to implement custom boolean/tri-state flags.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
diff --git a/bool.go b/bool.go
index 010576c..70e2e0a 100644
--- a/bool.go
+++ b/bool.go
@@ -5,6 +5,13 @@
 	"strconv"
 )
 
+// optional interface to indicate boolean flags that can be
+// supplied without "=value" text
+type boolFlag interface {
+	Value
+	IsBoolFlag() bool
+}
+
 // -- bool Value
 type boolValue bool
 
@@ -25,6 +32,8 @@
 
 func (b *boolValue) String() string { return fmt.Sprintf("%v", *b) }
 
+func (b *boolValue) IsBoolFlag() bool { return true }
+
 // BoolVar defines a bool flag with specified name, default value, and usage string.
 // The argument p points to a bool variable in which to store the value of the flag.
 func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) {
diff --git a/flag.go b/flag.go
index 47761a0..2e4cac0 100644
--- a/flag.go
+++ b/flag.go
@@ -466,7 +466,7 @@
 		return
 	}
 	if len(split) == 1 {
-		if _, ok := flag.Value.(*boolValue); !ok {
+		if bv, ok := flag.Value.(boolFlag); !ok || !bv.IsBoolFlag() {
 			err = f.failf("flag needs an argument: %s", s)
 			return
 		}
@@ -500,7 +500,7 @@
 			}
 		}
 		if alreadythere {
-			if _, ok := flag.Value.(*boolValue); ok {
+			if bv, ok := flag.Value.(boolFlag); ok && bv.IsBoolFlag() {
 				f.setFlag(flag, "true", s)
 				continue
 			}