2013-07-18 17:29:06 -07:00
|
|
|
package cli
|
|
|
|
|
|
|
|
type Command struct {
|
|
|
|
Name string
|
|
|
|
ShortName string
|
|
|
|
Usage string
|
|
|
|
Description string
|
|
|
|
Action Handler
|
|
|
|
Flags []Flag
|
|
|
|
}
|
2013-07-18 19:23:00 -07:00
|
|
|
|
|
|
|
func (command Command) Run(c *Context) {
|
|
|
|
set := flagSet(command.Flags)
|
|
|
|
set.Parse(c.Args()[1:])
|
2013-07-19 08:34:01 -07:00
|
|
|
command.Action(NewContext(c.App, set, c.globalSet))
|
2013-07-18 19:23:00 -07:00
|
|
|
}
|
2013-07-18 19:30:18 -07:00
|
|
|
|
|
|
|
func (command Command) HasName(name string) bool {
|
|
|
|
return command.Name == name || command.ShortName == name
|
|
|
|
}
|