Skip to content

Commit

Permalink
Isolate help message template
Browse files Browse the repository at this point in the history
  • Loading branch information
yudai committed Aug 21, 2015
1 parent 25627da commit 8758dc0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
19 changes: 19 additions & 0 deletions help.go
@@ -0,0 +1,19 @@
package main

var helpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} [options] <command> [<arguments...>]
VERSION:
{{.Version}}{{if or .Author .Email}}
AUTHOR:{{if .Author}}
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
{{.Email}}{{end}}{{end}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}
`
20 changes: 2 additions & 18 deletions main.go
Expand Up @@ -14,6 +14,7 @@ func main() {
cmd.Version = "0.0.2"
cmd.Name = "gotty"
cmd.Usage = "Share your terminal as a web application"
cmd.HideHelp = true
cmd.Flags = []cli.Flag{
cli.StringFlag{
Name: "addr, a",
Expand Down Expand Up @@ -66,24 +67,7 @@ func main() {
}
}

cmd.HideHelp = true
cli.AppHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
{{.Name}} [options] <command> [<arguments...>]
VERSION:
{{.Version}}{{if or .Author .Email}}
AUTHOR:{{if .Author}}
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
{{.Email}}{{end}}{{end}}
OPTIONS:
{{range .Flags}}{{.}}
{{end}}
`
cli.AppHelpTemplate = helpTemplate

cmd.Run(os.Args)
}

0 comments on commit 8758dc0

Please sign in to comment.