2021-01-31 23:10:16 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
// AppHelpTemplate is the text template for the Default help topic.
|
|
|
|
// cli.go uses text/template to render templates. You can
|
|
|
|
// render custom help text by setting this variable.
|
|
|
|
var AppHelpTemplate = `NAME:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{$v := offset .Name 6}}{{wrap .Name 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
USAGE:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{if .UsageText}}{{wrap .UsageText 3}}{{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}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
VERSION:
|
|
|
|
{{.Version}}{{end}}{{end}}{{if .Description}}
|
|
|
|
|
|
|
|
DESCRIPTION:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{wrap .Description 3}}{{end}}{{if len .Authors}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
|
|
|
|
{{range $index, $author := .Authors}}{{if $index}}
|
|
|
|
{{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}}
|
|
|
|
|
|
|
|
COMMANDS:{{range .VisibleCategories}}{{if .Name}}
|
|
|
|
{{.Name}}:{{range .VisibleCommands}}
|
|
|
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}}
|
2022-05-25 18:49:12 +00:00
|
|
|
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlagCategories}}
|
|
|
|
|
|
|
|
GLOBAL OPTIONS:{{range .VisibleFlagCategories}}
|
|
|
|
{{if .Name}}{{.Name}}
|
|
|
|
{{end}}{{range .Flags}}{{.}}
|
|
|
|
{{end}}{{end}}{{else}}{{if .VisibleFlags}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
GLOBAL OPTIONS:
|
|
|
|
{{range $index, $option := .VisibleFlags}}{{if $index}}
|
2022-06-20 11:31:57 +00:00
|
|
|
{{end}}{{wrap $option.String 6}}{{end}}{{end}}{{end}}{{if .Copyright}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
COPYRIGHT:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{wrap .Copyright 3}}{{end}}
|
2021-01-31 23:10:16 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
// CommandHelpTemplate is the text template for the command help topic.
|
|
|
|
// cli.go uses text/template to render templates. You can
|
|
|
|
// render custom help text by setting this variable.
|
|
|
|
var CommandHelpTemplate = `NAME:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{$v := offset .HelpName 6}}{{wrap .HelpName 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
USAGE:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Category}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
CATEGORY:
|
|
|
|
{{.Category}}{{end}}{{if .Description}}
|
|
|
|
|
|
|
|
DESCRIPTION:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{wrap .Description 3}}{{end}}{{if .VisibleFlagCategories}}
|
2022-05-25 18:49:12 +00:00
|
|
|
|
|
|
|
OPTIONS:{{range .VisibleFlagCategories}}
|
|
|
|
{{if .Name}}{{.Name}}
|
|
|
|
{{end}}{{range .Flags}}{{.}}
|
|
|
|
{{end}}{{end}}{{else}}{{if .VisibleFlags}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
OPTIONS:
|
|
|
|
{{range .VisibleFlags}}{{.}}
|
2022-05-25 18:49:12 +00:00
|
|
|
{{end}}{{end}}{{end}}
|
2021-01-31 23:10:16 +00:00
|
|
|
`
|
|
|
|
|
|
|
|
// SubcommandHelpTemplate is the text template for the subcommand help topic.
|
|
|
|
// cli.go uses text/template to render templates. You can
|
|
|
|
// render custom help text by setting this variable.
|
|
|
|
var SubcommandHelpTemplate = `NAME:
|
|
|
|
{{.HelpName}} - {{.Usage}}
|
|
|
|
|
|
|
|
USAGE:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{end}}{{if .Description}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
DESCRIPTION:
|
2022-06-20 11:31:57 +00:00
|
|
|
{{wrap .Description 3}}{{end}}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
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 .VisibleFlags}}{{.}}
|
|
|
|
{{end}}{{end}}
|
|
|
|
`
|
|
|
|
|
2022-03-16 11:55:03 +00:00
|
|
|
var MarkdownDocTemplate = `{{if gt .SectionNum 0}}% {{ .App.Name }} {{ .SectionNum }}
|
2021-01-31 23:10:16 +00:00
|
|
|
|
2022-03-16 11:55:03 +00:00
|
|
|
{{end}}# NAME
|
2021-01-31 23:10:16 +00:00
|
|
|
|
|
|
|
{{ .App.Name }}{{ if .App.Usage }} - {{ .App.Usage }}{{ end }}
|
|
|
|
|
|
|
|
# SYNOPSIS
|
|
|
|
|
|
|
|
{{ .App.Name }}
|
|
|
|
{{ if .SynopsisArgs }}
|
|
|
|
` + "```" + `
|
|
|
|
{{ range $v := .SynopsisArgs }}{{ $v }}{{ end }}` + "```" + `
|
2022-03-16 11:55:03 +00:00
|
|
|
{{ end }}{{ if .App.Description }}
|
2021-01-31 23:10:16 +00:00
|
|
|
# DESCRIPTION
|
|
|
|
|
2022-03-16 11:55:03 +00:00
|
|
|
{{ .App.Description }}
|
2021-01-31 23:10:16 +00:00
|
|
|
{{ end }}
|
|
|
|
**Usage**:
|
|
|
|
|
2022-03-16 11:55:03 +00:00
|
|
|
` + "```" + `{{ if .App.UsageText }}
|
|
|
|
{{ .App.UsageText }}
|
|
|
|
{{ else }}
|
2021-01-31 23:10:16 +00:00
|
|
|
{{ .App.Name }} [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
|
2022-03-16 11:55:03 +00:00
|
|
|
{{ end }}` + "```" + `
|
2021-01-31 23:10:16 +00:00
|
|
|
{{ if .GlobalArgs }}
|
|
|
|
# GLOBAL OPTIONS
|
|
|
|
{{ range $v := .GlobalArgs }}
|
|
|
|
{{ $v }}{{ end }}
|
|
|
|
{{ end }}{{ if .Commands }}
|
|
|
|
# COMMANDS
|
|
|
|
{{ range $v := .Commands }}
|
|
|
|
{{ $v }}{{ end }}{{ end }}`
|
|
|
|
|
|
|
|
var FishCompletionTemplate = `# {{ .App.Name }} fish shell completion
|
|
|
|
|
|
|
|
function __fish_{{ .App.Name }}_no_subcommand --description 'Test if there has been any subcommand yet'
|
|
|
|
for i in (commandline -opc)
|
|
|
|
if contains -- $i{{ range $v := .AllCommands }} {{ $v }}{{ end }}
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
|
|
|
|
{{ range $v := .Completions }}{{ $v }}
|
|
|
|
{{ end }}`
|