add ability to parse []string types

This commit is contained in:
Thesyncim
2013-09-24 02:41:31 +01:00
parent e8d8047f49
commit 4d9038a156
3 changed files with 54 additions and 8 deletions

View File

@@ -34,6 +34,10 @@ func (c *Context) String(name string) string {
return c.lookupString(name, c.flagSet)
}
func (c *Context) StringSlice(name string) flag.Value {
return c.lookupStringSlice(name, c.flagSet)
}
// Looks up the value of a global int flag, returns 0 if no int flag exists
func (c *Context) GlobalInt(name string) int {
return c.lookupInt(name, c.globalSet)
@@ -75,6 +79,15 @@ func (c *Context) lookupString(name string, set *flag.FlagSet) string {
return ""
}
func (c *Context) lookupStringSlice(name string, set *flag.FlagSet) flag.Value {
f := set.Lookup(name)
if f != nil {
return f.Value
}
return nil
}
func (c *Context) lookupBool(name string, set *flag.FlagSet) bool {
f := set.Lookup(name)
if f != nil {