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
This commit is contained in:
Jeremy Saenz 2013-07-14 18:17:15 -07:00
parent bdb9c5ab61
commit 5a624affb8
2 changed files with 8 additions and 4 deletions

1
cli.go
View File

@ -40,3 +40,4 @@ type Command struct {
}
type Action func(name string)

11
help.go
View File

@ -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,
}