Added two convenience functions for retrieving arguments

This commit is contained in:
Alexander Rødseth 2013-11-15 11:30:45 +01:00
parent ea3ef24c9d
commit 30d83a70a7

View File

@ -129,3 +129,17 @@ func (c *Context) lookupBool(name string, set *flag.FlagSet) bool {
return false
}
// Returns the nth argument, or just a blank string
func (c *Context) GetArg(n int) string {
args := c.Args()
if len(args) < n {
return args[n]
}
return ""
}
// Returns the first argument, or just a blank string, for convenience
func (c *Context) FirstArg() string {
return c.GetArg(0)
}