diff --git a/help.go b/help.go index bd92c0d..9660022 100644 --- a/help.go +++ b/help.go @@ -1,8 +1,6 @@ package cli import "os" -import "log" - import "text/tabwriter" import "text/template" @@ -20,23 +18,20 @@ var HelpCommand = Command{ Action: ShowHelp, } -var helpTemplate = `NAME: - {{.Name}} - {{.Usage}} +var ShowHelp = func(name string) { + helpTemplate := `NAME: + {{.Name}} - {{.Usage}} USAGE: - {{.Name}} [global-options] COMMAND [command-options] + {{.Name}} [global options] command [command options] [arguments...] VERSION: - {{.Version}} + {{.Version}} COMMANDS: - {{range .Commands}}{{.Name}}{{ "\t" }}{{.Usage}} - {{end}} - + {{range .Commands}}{{.Name}}{{ "\t" }}{{.Usage}} + {{end}} ` - -var ShowHelp = func(name string) { - data := HelpData{ Name, Usage, @@ -46,17 +41,6 @@ var ShowHelp = func(name string) { w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0) t := template.Must(template.New("help").Parse(helpTemplate)) - err := t.Execute(w, data) + t.Execute(w, data) w.Flush() - if err != nil { - log.Println("executing template:", err) - } - // fmt.Printf("Usage: %v [global-options] COMMAND [command-options]\n\n", Name) - // if Commands != nil { - // fmt.Printf("The most commonly used %v commands are:\n", Name) - // for _, c := range Commands { - // fmt.Fprintln(w, " "+c.Name+"\t"+c.Usage) - // } - // w.Flush() - // } }