Merge pull request #1065 from hairyhenderson/reformat-usage-1014

Reformatting usage message to look more like docker's
This commit is contained in:
Evan Hazlett 2015-04-30 09:27:13 -04:00
commit b99e32e819
1 changed files with 35 additions and 0 deletions

35
main.go
View File

@ -12,6 +12,39 @@ import (
"github.com/docker/machine/version" "github.com/docker/machine/version"
) )
var AppHelpTemplate = `
Usage: {{.Name}} {{if .Flags}}[OPTIONS] {{end}}COMMAND [arg...]
{{.Usage}}
Version: {{.Version}}{{if or .Author .Email}}
Author:{{if .Author}}
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
{{.Email}}{{end}}{{end}}
{{if .Flags}}
Options:
{{range .Flags}}{{.}}
{{end}}{{end}}
Commands:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}
Run '{{.Name}} COMMAND --help' for more information on a command.
`
var CommandHelpTemplate = `
Usage: docker-machine {{.Name}}{{if .Flags}} [OPTIONS]{{end}} [arg...]
{{.Usage}}{{if .Description}}
Description:
{{.Description}}{{end}}{{if .Flags}}
Options:
{{range .Flags}}{{.}}
{{end}}{{ end }}
`
func main() { func main() {
for _, f := range os.Args { for _, f := range os.Args {
if f == "-D" || f == "--debug" || f == "-debug" { if f == "-D" || f == "--debug" || f == "-debug" {
@ -20,6 +53,8 @@ func main() {
} }
} }
cli.AppHelpTemplate = AppHelpTemplate
cli.CommandHelpTemplate = CommandHelpTemplate
app := cli.NewApp() app := cli.NewApp()
app.Name = path.Base(os.Args[0]) app.Name = path.Base(os.Args[0])
app.Author = "Docker Machine Contributors" app.Author = "Docker Machine Contributors"