From 63b9f2823a654645c76e4a86d6fb41b866ee830a Mon Sep 17 00:00:00 2001 From: Jeremy Saenz Date: Fri, 19 Jul 2013 15:10:34 -0700 Subject: [PATCH] JMS #14: Improved help. Brought help commadn back to commands --- app.go | 6 +++++- help.go | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app.go b/app.go index ebbdd4b..974ecd6 100644 --- a/app.go +++ b/app.go @@ -28,14 +28,18 @@ func NewApp() *App { } func (a *App) Run(arguments []string) { + // parse flags set := flagSet(a.Flags) set.Parse(arguments[1:]) + // append help to commands + a.Commands = append(a.Commands, HelpCommand) + context := NewContext(a, set, set) args := context.Args() if len(args) > 0 { name := args[0] - for _, c := range append(a.Commands, HelpCommand) { + for _, c := range a.Commands { if c.HasName(name) { c.Run(context) return diff --git a/help.go b/help.go index ffe5b28..7d5a0c1 100644 --- a/help.go +++ b/help.go @@ -8,10 +8,7 @@ var HelpCommand = Command{ Name: "help", ShortName: "h", Usage: "Shows a list of commands or help for one command", -} - -func init() { - HelpCommand.Action = ShowHelp + Action: ShowHelp, } func ShowHelp(c *Context) {