JMS #28: -h flags for subcommands

This commit is contained in:
Jeremy Saenz
2013-08-13 21:40:39 -07:00
parent 61d5778536
commit 8cea424806
2 changed files with 18 additions and 1 deletions
+11 -1
View File
@@ -10,9 +10,19 @@ type Command struct {
}
func (c Command) Run(ctx *Context) {
// append help to flags
c.Flags = append(
c.Flags,
helpFlag{"show help"},
)
set := flagSet(c.Name, c.Flags)
set.Parse(ctx.Args()[1:])
c.Action(NewContext(ctx.App, set, ctx.globalSet))
context := NewContext(ctx.App, set, ctx.globalSet)
checkCommandHelp(context, c.Name)
c.Action(context)
}
func (c Command) HasName(name string) bool {