From 5a624affb8c13ff95d458311915a73a6e266541a Mon Sep 17 00:00:00 2001 From: Jeremy Saenz Date: Sun, 14 Jul 2013 18:17:15 -0700 Subject: [PATCH] Yo dawg, I heard you liked the help command... So I described the help command in your help command so you can help command while you help command --- cli.go | 1 + help.go | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cli.go b/cli.go index d7c7628..e4bce23 100644 --- a/cli.go +++ b/cli.go @@ -40,3 +40,4 @@ type Command struct { } type Action func(name string) + diff --git a/help.go b/help.go index bb13b81..840ef67 100644 --- a/help.go +++ b/help.go @@ -14,11 +14,14 @@ type HelpData struct { var HelpCommand = Command{ Name: "help", ShortName: "h", - Usage: "View help topics", - Action: ShowHelp, + Usage: "Shows a list of commands or help for one command", } -var ShowHelp = func(name string) { +func init() { + HelpCommand.Action = ShowHelp +} + +func ShowHelp(name string) { helpTemplate := `NAME: {{.Name}} - {{.Usage}} @@ -35,7 +38,7 @@ COMMANDS: data := HelpData{ Name, Usage, - Commands, + append(Commands, HelpCommand), Version, }