Added two convenience functions for retrieving arguments
This commit is contained in:
parent
ea3ef24c9d
commit
30d83a70a7
14
context.go
14
context.go
@ -129,3 +129,17 @@ func (c *Context) lookupBool(name string, set *flag.FlagSet) bool {
|
|||||||
|
|
||||||
return false
|
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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user