1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-18 03:56:52 +02:00
Carlos Alexandro Becker 17a894981f
fix: CLI improvements (#936)
* fix: CLI improvements

* fix: CLI improvements

* fix: CLI improvements

* chore: lint
2019-01-22 01:12:17 -02:00

55 lines
1.4 KiB
Go

package static
// UsageTemplate for goreleaser CLI.
// nolint: gochecknoglobals
const UsageTemplate = `{{define "FormatCommand"}}\
{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
{{end}}\
{{define "FormatCommands"}}\
{{range .FlattenedCommands}}\
{{if not .Hidden}}\
{{.FullCommand}}{{template "FormatCommand" .}}{{if .Default}} (default){{end}}
{{.Help|Wrap 4}}
{{end}}\
{{end}}\
{{end}}\
{{define "FormatUsage"}}\
{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
{{end}}\
{{if .Context.SelectedCommand}}\
{{with .Context.SelectedCommand.Help}}\
{{. | Wrap 0}}
{{end}}\
{{else}}\
{{.App.Help | Wrap 0}}
{{end}}\
USAGE:
{{if .Context.SelectedCommand}}\
$ {{.App.Name}} {{.Context.SelectedCommand}}{{template "FormatUsage" .Context.SelectedCommand}}
{{else}}\
$ {{.App.Name}}{{template "FormatUsage" .App}}
{{end}}\
{{if .Context.Flags}}\
FLAGS:
{{.Context.Flags|FlagsToTwoColumns|FormatTwoColumns}}
{{end}}\
{{if .Context.Args}}\
ARGS:
{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
{{end}}\
{{if .Context.SelectedCommand}}\
{{if len .Context.SelectedCommand.Commands}}\
SUBCOMMANDS:
{{template "FormatCommands" .Context.SelectedCommand}}
{{end}}\
{{else if .App.Commands}}\
COMMANDS:
{{template "FormatCommands" .App}}
{{end}}\
`