JMS #28: -h flags for subcommands
This commit is contained in:
parent
61d5778536
commit
8cea424806
12
command.go
12
command.go
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user