JMS #14: More help cleanup
This commit is contained in:
34
help.go
34
help.go
@@ -4,33 +4,31 @@ import "os"
|
||||
import "text/tabwriter"
|
||||
import "text/template"
|
||||
|
||||
var HelpCommand = Command{
|
||||
var helpCommand = Command{
|
||||
Name: "help",
|
||||
ShortName: "h",
|
||||
Usage: "Shows a list of commands or help for one command",
|
||||
Action: ShowHelp,
|
||||
}
|
||||
|
||||
func ShowHelp(c *Context) {
|
||||
helpTemplate := `NAME:
|
||||
{{.Name}} - {{.Usage}}
|
||||
Action: func(c *Context) {
|
||||
helpTemplate := `NAME:
|
||||
{{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.Name}} [global options] command [command options] [arguments...]
|
||||
{{.Name}} [global options] command [command options] [arguments...]
|
||||
|
||||
VERSION:
|
||||
{{.Version}}
|
||||
{{.Version}}
|
||||
|
||||
COMMANDS:
|
||||
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
||||
{{end}}
|
||||
GLOBAL OPTIONS
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}
|
||||
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
||||
{{end}}
|
||||
GLOBAL OPTIONS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}
|
||||
`
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
|
||||
t := template.Must(template.New("help").Parse(helpTemplate))
|
||||
t.Execute(w, c.App)
|
||||
w.Flush()
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
|
||||
t := template.Must(template.New("help").Parse(helpTemplate))
|
||||
t.Execute(w, c.App)
|
||||
w.Flush()
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user