Show usage options in help string

This commit is contained in:
Gyepi Sam 2013-05-20 16:27:15 -04:00
parent 3c6b6c35c4
commit 1cae7f2834

10
main.go
View File

@ -45,15 +45,21 @@ func main() {
} }
func usage() { func usage() {
fmt.Print(usagePrefix)
flag.PrintDefaults()
usageTmpl.Execute(os.Stdout, commands) usageTmpl.Execute(os.Stdout, commands)
} }
var usageTmpl = template.Must(template.New("usage").Parse( var usagePrefix = `
`goose is a database migration management system for Go projects. goose is a database migration management system for Go projects.
Usage: Usage:
goose [options] <subcommand> [subcommand options] goose [options] <subcommand> [subcommand options]
Options:
`
var usageTmpl = template.Must(template.New("usage").Parse(
`
Commands:{{range .}} Commands:{{range .}}
{{.Name | printf "%-10s"}} {{.Summary}}{{end}} {{.Name | printf "%-10s"}} {{.Summary}}{{end}}
`)) `))