From d6d4e6448b03fcbff51263649b9b5a012acac650 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 13 Jul 2014 14:27:44 +0100 Subject: [PATCH] Hide "Options" sections in help, if no flags are defined --- help.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/help.go b/help.go index 7c04005..845e805 100644 --- a/help.go +++ b/help.go @@ -14,17 +14,17 @@ var AppHelpTemplate = `NAME: {{.Name}} - {{.Usage}} USAGE: - {{.Name}} [global options] command [command options] [arguments...] + {{.Name}} {{ if .Flags }}[global options] {{ end }}command{{ if .Flags }} [command options]{{ end }} [arguments...] VERSION: {{.Version}} COMMANDS: {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}} - {{end}} + {{end}}{{ if .Flags }} GLOBAL OPTIONS: {{range .Flags}}{{.}} - {{end}} + {{end}}{{ end }} ` // The text template for the command help topic. @@ -34,14 +34,14 @@ var CommandHelpTemplate = `NAME: {{.Name}} - {{.Usage}} USAGE: - command {{.Name}} [command options] [arguments...] + command {{.Name}}{{ if .Flags }} [command options]{{ end }} [arguments...] DESCRIPTION: - {{.Description}} + {{.Description}}{{ if .Flags }} OPTIONS: {{range .Flags}}{{.}} - {{end}} + {{end}}{{ end }} ` // The text template for the subcommand help topic. @@ -51,14 +51,14 @@ var SubcommandHelpTemplate = `NAME: {{.Name}} - {{.Usage}} USAGE: - {{.Name}} [global options] command [command options] [arguments...] + {{.Name}} [global options] command{{ if .Flags }} [command options]{{ end }} [arguments...] COMMANDS: {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}} - {{end}} + {{end}}{{ if .Flags }} OPTIONS: {{range .Flags}}{{.}} - {{end}} + {{end}}{{ end }} ` var helpCommand = Command{