2013-07-19 00:29:06 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
type Command struct {
|
|
|
|
Name string
|
|
|
|
ShortName string
|
|
|
|
Usage string
|
|
|
|
Description string
|
2013-07-20 22:50:13 +00:00
|
|
|
Action func(context *Context)
|
2013-07-19 00:29:06 +00:00
|
|
|
Flags []Flag
|
|
|
|
}
|
2013-07-19 02:23:00 +00:00
|
|
|
|
2013-07-20 15:21:20 +00:00
|
|
|
func (c Command) Run(ctx *Context) {
|
|
|
|
set := flagSet(c.Name, c.Flags)
|
|
|
|
set.Parse(ctx.Args()[1:])
|
|
|
|
c.Action(NewContext(ctx.App, set, ctx.globalSet))
|
2013-07-19 02:23:00 +00:00
|
|
|
}
|
2013-07-19 02:30:18 +00:00
|
|
|
|
2013-07-20 15:21:20 +00:00
|
|
|
func (c Command) HasName(name string) bool {
|
|
|
|
return c.Name == name || c.ShortName == name
|
2013-07-19 02:30:18 +00:00
|
|
|
}
|