Proper help text & new README structure #311

Merged
lunny merged 11 commits from noerw/tea:improve-app-help into master 2020-12-21 13:37:21 +00:00
Showing only changes of commit 946162b6fe - Show all commits

32
main.go
View File

@ -24,8 +24,7 @@ var Tags = ""
func main() {
app := cli.NewApp()
app.Name = "tea"
app.Usage = "Command line tool to interact with Gitea"
app.Description = ``
app.CustomAppHelpTemplate = helpTemplate
app.Version = Version + formatBuiltWith(Tags)
app.Commands = []*cli.Command{
&cmd.CmdLogin,
@ -55,3 +54,32 @@ func formatBuiltWith(Tags string) string {
return " built with: " + strings.Replace(Tags, " ", ", ", -1)
}
var helpTemplate = `NAME:
{{.Name}}{{if .Usage}} - {{.Usage}}{{end}}
USAGE:
{{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}}
VERSION:
{{.Version}}{{end}}{{end}}{{if .Description}}
DESCRIPTION:
{{.Description | nindent 3 | trim}}{{end}}{{if len .Authors}}
AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}:
noerw marked this conversation as resolved Outdated
Outdated
Review
-or multiple Gitea instances, and also provides local helpers like 'tea pull checkout'.
+or multiple Gitea instances and provides local helpers like 'tea pull checkout'.
```diff -or multiple Gitea instances, and also provides local helpers like 'tea pull checkout'. +or multiple Gitea instances and provides local helpers like 'tea pull checkout'.
{{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}}
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}}
GLOBAL OPTIONS:
{{range $index, $option := .VisibleFlags}}{{if $index}}
{{end}}{{$option}}{{end}}{{end}}{{if .Copyright}}
COPYRIGHT:
{{.Copyright}}{{end}}
`