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:
parent
bdb9c5ab61
commit
5a624affb8
1
cli.go
1
cli.go
@ -40,3 +40,4 @@ type Command struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Action func(name string)
|
type Action func(name string)
|
||||||
|
|
||||||
|
11
help.go
11
help.go
@ -14,11 +14,14 @@ type HelpData struct {
|
|||||||
var HelpCommand = Command{
|
var HelpCommand = Command{
|
||||||
Name: "help",
|
Name: "help",
|
||||||
ShortName: "h",
|
ShortName: "h",
|
||||||
Usage: "View help topics",
|
Usage: "Shows a list of commands or help for one command",
|
||||||
Action: ShowHelp,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ShowHelp = func(name string) {
|
func init() {
|
||||||
|
HelpCommand.Action = ShowHelp
|
||||||
|
}
|
||||||
|
|
||||||
|
func ShowHelp(name string) {
|
||||||
helpTemplate := `NAME:
|
helpTemplate := `NAME:
|
||||||
{{.Name}} - {{.Usage}}
|
{{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
@ -35,7 +38,7 @@ COMMANDS:
|
|||||||
data := HelpData{
|
data := HelpData{
|
||||||
Name,
|
Name,
|
||||||
Usage,
|
Usage,
|
||||||
Commands,
|
append(Commands, HelpCommand),
|
||||||
Version,
|
Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user