Make "BoolFlag" booleans not require =true

This commit is contained in:
Eric Paris
2016-01-08 11:42:06 -05:00
parent 46945ab50f
commit aad4b4477d
7 changed files with 18 additions and 13 deletions

View File

@@ -22,8 +22,9 @@ import (
)
// BoolFlag is a boolean flag compatible with flags and pflags that keeps track of whether it had a value supplied or not.
// Beware! If you use this type, you must actually specify --flag-name=true, you cannot leave it as --flag-name and still have
// the value set
// Getting this flag to act like a normal bool, where true/false are not required needs a little bit of extra code, example:
// f := cmd.Flags().VarPF(&BoolFlagVar, "flagname", "", "help about the flag")
// f.NoOptDefVal = "true"
type BoolFlag struct {
// If Set has been invoked this value is true
provided bool