// MayBool tries to convert any of related aliases to bool func (am ArgMap) MayBool(defaultValue bool, aliases ...string) bool { for _, key := range aliases { b, err := to.Bool(am[key]) if err == nil { return b } } return defaultValue }
// AsBool tries to convert any of related aliases to bool func (am ArgMap) AsBool(aliases ...string) bool { for _, key := range aliases { b, err := to.Bool(am[key]) if err == nil { return b } } return false }
// MustBool tries to convert any of related aliases to bool. If no keys // it panics. func (am ArgMap) MustBool(aliases ...string) bool { for _, key := range aliases { if am[key] == nil { continue } b, err := to.Bool(am[key]) if err != nil { panic(err) } return b } panic(fmt.Sprintf("None of these bool flags were found: %v", aliases)) }