Removed error handling and cleaned up template

This commit is contained in:
Jeremy Saenz 2013-07-14 17:53:34 -07:00
parent 5b788be8a6
commit 9186f6e81a

32
help.go
View File

@ -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()
// }
}