Allow bool flags to be set to true or false explicitly.
This commit is contained in:
@@ -211,7 +211,12 @@ func (r *Registry) RegisterDefaults() *Registry {
|
||||
type boolMapper struct{}
|
||||
|
||||
func (boolMapper) Decode(ctx *DecodeContext, target reflect.Value) error {
|
||||
target.SetBool(true)
|
||||
if ctx.Scan.Peek().Type == FlagValueToken {
|
||||
token := ctx.Scan.Pop()
|
||||
target.SetBool(token.Value == "true")
|
||||
} else {
|
||||
target.SetBool(true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (boolMapper) IsBool() bool { return true }
|
||||
|
||||
Reference in New Issue
Block a user