You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
418 B
21 lines
418 B
package cli
|
|
|
|
type Command struct {
|
|
Name string
|
|
ShortName string
|
|
Usage string
|
|
Description string
|
|
Action func(context *Context)
|
|
Flags []Flag
|
|
}
|
|
|
|
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))
|
|
}
|
|
|
|
func (c Command) HasName(name string) bool {
|
|
return c.Name == name || c.ShortName == name
|
|
}
|