1package cli
2
3// AppHelpTemplate is the text template for the Default help topic.
4// cli.go uses text/template to render templates. You can
5// render custom help text by setting this variable.
6var AppHelpTemplate = `NAME:
7   {{.Name}}{{if .Usage}} - {{.Usage}}{{end}}
8
9USAGE:
10   {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Version}}{{if not .HideVersion}}
11
12VERSION:
13   {{.Version}}{{end}}{{end}}{{if .Description}}
14
15DESCRIPTION:
16   {{.Description}}{{end}}{{if len .Authors}}
17
18AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
19   {{range $index, $author := .Authors}}{{if $index}}
20   {{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}}
21
22COMMANDS:{{range .VisibleCategories}}{{if .Name}}
23   {{.Name}}:{{range .VisibleCommands}}
24     {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
25   {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
26
27GLOBAL OPTIONS:
28   {{range $index, $option := .VisibleFlags}}{{if $index}}
29   {{end}}{{$option}}{{end}}{{end}}{{if .Copyright}}
30
31COPYRIGHT:
32   {{.Copyright}}{{end}}
33`
34
35// CommandHelpTemplate is the text template for the command help topic.
36// cli.go uses text/template to render templates. You can
37// render custom help text by setting this variable.
38var CommandHelpTemplate = `NAME:
39   {{.HelpName}} - {{.Usage}}
40
41USAGE:
42   {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}}
43
44CATEGORY:
45   {{.Category}}{{end}}{{if .Description}}
46
47DESCRIPTION:
48   {{.Description}}{{end}}{{if .VisibleFlags}}
49
50OPTIONS:
51   {{range .VisibleFlags}}{{.}}
52   {{end}}{{end}}
53`
54
55// SubcommandHelpTemplate is the text template for the subcommand help topic.
56// cli.go uses text/template to render templates. You can
57// render custom help text by setting this variable.
58var SubcommandHelpTemplate = `NAME:
59   {{.HelpName}} - {{.Usage}}
60
61USAGE:
62   {{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
63
64DESCRIPTION:
65   {{.Description}}{{end}}
66
67COMMANDS:{{range .VisibleCategories}}{{if .Name}}
68   {{.Name}}:{{range .VisibleCommands}}
69     {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
70   {{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
71
72OPTIONS:
73   {{range .VisibleFlags}}{{.}}
74   {{end}}{{end}}
75`
76
77var MarkdownDocTemplate = `% {{ .App.Name }} 8
78
79# NAME
80
81{{ .App.Name }}{{ if .App.Usage }} - {{ .App.Usage }}{{ end }}
82
83# SYNOPSIS
84
85{{ .App.Name }}
86{{ if .SynopsisArgs }}
87` + "```" + `
88{{ range $v := .SynopsisArgs }}{{ $v }}{{ end }}` + "```" + `
89{{ end }}{{ if .App.UsageText }}
90# DESCRIPTION
91
92{{ .App.UsageText }}
93{{ end }}
94**Usage**:
95
96` + "```" + `
97{{ .App.Name }} [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
98` + "```" + `
99{{ if .GlobalArgs }}
100# GLOBAL OPTIONS
101{{ range $v := .GlobalArgs }}
102{{ $v }}{{ end }}
103{{ end }}{{ if .Commands }}
104# COMMANDS
105{{ range $v := .Commands }}
106{{ $v }}{{ end }}{{ end }}`
107
108var FishCompletionTemplate = `# {{ .App.Name }} fish shell completion
109
110function __fish_{{ .App.Name }}_no_subcommand --description 'Test if there has been any subcommand yet'
111    for i in (commandline -opc)
112        if contains -- $i{{ range $v := .AllCommands }} {{ $v }}{{ end }}
113            return 1
114        end
115    end
116    return 0
117end
118
119{{ range $v := .Completions }}{{ $v }}
120{{ end }}`
121