/
template.go
77 lines (63 loc) · 2.25 KB
/
template.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package pkg
import "github.com/MakeNowJust/heredoc"
// AppHelpTemplate is a custom template for the CLI help message.
var AppHelpTemplate = heredoc.Doc(`
Usage: {{ .HelpName }} [global options] command [command options] [arguments ...]
{{ .Usage }}
Commands:{{range .VisibleCategories}}{{if .Name}}
{{.Name}}:{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
Options:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}{{end}}
Run '{{ .HelpName }} [command] --help' for more information about a command.
`)
// CommandHelpTemplate is a custom template for the CLI command help messages.
var CommandHelpTemplate = heredoc.Doc(`
Usage: {{ .HelpName }}{{ if .VisibleFlags }} [options]{{ end }} {{ if .ArgsUsage }}{{ .ArgsUsage }}{{ else }}[arguments...]{{ end }}
{{ .Usage }}{{ if .Description }}
{{ .Description }}{{ end }}{{if .VisibleFlags}}
Options:
{{range .VisibleFlags}}{{.}}
{{end}}{{end}}
`)
// CommandVersionTemplate is the template for the CLI version output.
var CommandVersionTemplate = heredoc.Doc(`
envsnap:
version: {{ .Version }}
build date: {{ .BuildDate }}
commit: {{ .Commit }}
tag: {{ .Tag }}
go version: {{ .GoVersion }}
go compiler: {{ .Compiler }}
platform: {{ .OS }}/{{ .Arch }}
`)
// EnvsnapInitTemplate is the template for the boilerplate envsnap config.
var EnvsnapInitTemplate = heredoc.Doc(`
# envsnap configuration (yaml format)
# use 'envsnap show' to generate an environment snapshot
# for more details, see: https://www.github.com/edaniszewski/envsnap
version: {{ .Version }}
{{ if not .Terse }}
# System configurations provide details about the user's system.{{ end }}
system:
core:
- os
- arch
{{ if .RenderPython -}}
{{ if not .Terse }}
# Python configurations provide details about the user's Python
# installation and dependencies.{{ end }}
python:
core:
- version
dependencies: []
{{ end }}{{ if .RenderGolang -}}
{{ if not .Terse }}
# Golang configurations provide details about the user's Go installation.{{ end }}
go:
core:
- version
{{ end -}}
`)