-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.go
36 lines (25 loc) · 864 Bytes
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// +build doc
package main
import (
"log"
"strings"
)
func main() {
App.CustomAppHelpTemplate = helpTpl
err := App.Run([]string{"--help"})
if err == nil {
return
}
if strings.Contains(err.Error(), "Required flags") {
return
}
log.Fatalf("failed to generate docs. %s", err)
}
const helpTpl = `## Configuration
Following configuration flags are supported by ` + "`tile38-cluster-manager`" + `.
Configuration can be provided either via command line flags or the environment variables mentioned against each flag.
{{range $index, $flag := .VisibleFlags}}{{if ne $flag.Name "help"}}
==` + "`--{{$flag.Name}}`" + ` ` + "`({{if $flag.Required}}required{{else}}optional{{end}}: {{if $flag.Value}}{{$flag.Value}}{{else}}\"\"{{end}})`, `env: " + `{{join $flag.EnvVars "` + "`" + `, ` + "`" + `"}}` + "`" + `==
: {{$flag.Usage}}
{{end}}{{end}}
`