aboutsummaryrefslogtreecommitdiff
path: root/bool.go
diff options
context:
space:
mode:
Diffstat (limited to 'bool.go')
-rw-r--r--bool.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/bool.go b/bool.go
index 010576c..70e2e0a 100644
--- a/bool.go
+++ b/bool.go
@@ -5,6 +5,13 @@ import (
"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) Type() string {
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) {