Hide "Options" sections in help, if no flags are defined
This commit is contained in:
parent
4a645835f0
commit
d6d4e6448b
18
help.go
18
help.go
@ -14,17 +14,17 @@ var AppHelpTemplate = `NAME:
|
|||||||
{{.Name}} - {{.Usage}}
|
{{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
{{.Name}} [global options] command [command options] [arguments...]
|
{{.Name}} {{ if .Flags }}[global options] {{ end }}command{{ if .Flags }} [command options]{{ end }} [arguments...]
|
||||||
|
|
||||||
VERSION:
|
VERSION:
|
||||||
{{.Version}}
|
{{.Version}}
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
||||||
{{end}}
|
{{end}}{{ if .Flags }}
|
||||||
GLOBAL OPTIONS:
|
GLOBAL OPTIONS:
|
||||||
{{range .Flags}}{{.}}
|
{{range .Flags}}{{.}}
|
||||||
{{end}}
|
{{end}}{{ end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
// The text template for the command help topic.
|
// The text template for the command help topic.
|
||||||
@ -34,14 +34,14 @@ var CommandHelpTemplate = `NAME:
|
|||||||
{{.Name}} - {{.Usage}}
|
{{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
command {{.Name}} [command options] [arguments...]
|
command {{.Name}}{{ if .Flags }} [command options]{{ end }} [arguments...]
|
||||||
|
|
||||||
DESCRIPTION:
|
DESCRIPTION:
|
||||||
{{.Description}}
|
{{.Description}}{{ if .Flags }}
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
{{range .Flags}}{{.}}
|
{{range .Flags}}{{.}}
|
||||||
{{end}}
|
{{end}}{{ end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
// The text template for the subcommand help topic.
|
// The text template for the subcommand help topic.
|
||||||
@ -51,14 +51,14 @@ var SubcommandHelpTemplate = `NAME:
|
|||||||
{{.Name}} - {{.Usage}}
|
{{.Name}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
{{.Name}} [global options] command [command options] [arguments...]
|
{{.Name}} [global options] command{{ if .Flags }} [command options]{{ end }} [arguments...]
|
||||||
|
|
||||||
COMMANDS:
|
COMMANDS:
|
||||||
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
|
||||||
{{end}}
|
{{end}}{{ if .Flags }}
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
{{range .Flags}}{{.}}
|
{{range .Flags}}{{.}}
|
||||||
{{end}}
|
{{end}}{{ end }}
|
||||||
`
|
`
|
||||||
|
|
||||||
var helpCommand = Command{
|
var helpCommand = Command{
|
||||||
|
Loading…
Reference in New Issue
Block a user