adding support for Float64SliceFlag

This commit is contained in:
Bruno França dos Reis
2016-06-28 19:52:25 -07:00
parent ee464a6db7
commit 028af4bc35
3 changed files with 221 additions and 0 deletions

View File

@@ -84,6 +84,15 @@ func (c *Context) Int64Slice(name string) []int64 {
return nil
}
// Float64Slice looks up the value of a local float64 slice flag, returns nil if no float
// slice flag exists
func (c *Context) Float64Slice(name string) []float64 {
if fs := lookupFlagSet(name, c); fs != nil {
return lookupFloat64Slice(name, fs)
}
return nil
}
// Bool looks up the value of a local bool flag, returns false if no bool flag exists
func (c *Context) Bool(name string) bool {
if fs := lookupFlagSet(name, c); fs != nil {
@@ -317,6 +326,14 @@ func lookupInt64Slice(name string, set *flag.FlagSet) []int64 {
return nil
}
func lookupFloat64Slice(name string, set *flag.FlagSet) []float64 {
f := set.Lookup(name)
if f != nil {
return (f.Value.(*Float64Slice)).Value()
}
return nil
}
func lookupGeneric(name string, set *flag.FlagSet) interface{} {
f := set.Lookup(name)
if f != nil {