JMS #4: Delegating to Command.Run

main
Jeremy Saenz 11 years ago
parent 87d3b81d55
commit 4495e2e996

@ -30,9 +30,7 @@ func Run(arguments []string) {
name := args[0]
for _, c := range append(Commands, HelpCommand) {
if c.Name == name || c.ShortName == name {
locals := flagSet(c.Flags)
locals.Parse(args[1:])
c.Action(NewContext(locals, set))
c.Run(context)
return
}
}

@ -8,3 +8,9 @@ type Command struct {
Action Handler
Flags []Flag
}
func (command Command) Run(c *Context) {
set := flagSet(command.Flags)
set.Parse(c.Args()[1:])
command.Action(NewContext(set, c.globalSet))
}

Loading…
Cancel
Save