aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-10 23:44:48 +0800
committerFelix Lange <fjl@twurst.com>2015-03-10 23:44:48 +0800
commit972e2c1e31067a9bab77228c19348b66964ce643 (patch)
treee2f718729e21bb05b154185e83c8458b74849c9b /cmd/utils/flags.go
parent221fae411278825dcaa0ec4058f065752046869b (diff)
downloadgo-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.tar
go-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.tar.gz
go-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.tar.bz2
go-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.tar.lz
go-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.tar.xz
go-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.tar.zst
go-tangerine-972e2c1e31067a9bab77228c19348b66964ce643.zip
cmd/utils: improve CLI help templates
Help for a specific command now shows available subcommands.
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 97d312dd4..e945a32ee 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -24,11 +24,38 @@ import (
"github.com/ethereum/go-ethereum/xeth"
)
+func init() {
+ cli.AppHelpTemplate = `{{.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}}{{if .Flags}}
+GLOBAL OPTIONS:
+ {{range .Flags}}{{.}}
+ {{end}}{{end}}
+`
+
+ cli.CommandHelpTemplate = `{{.Name}}{{if .Subcommands}} command{{end}}{{if .Flags}} [command options]{{end}} [arguments...]
+{{if .Description}}{{.Description}}
+{{end}}{{if .Subcommands}}
+SUBCOMMANDS:
+ {{range .Subcommands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
+ {{end}}{{end}}{{if .Flags}}
+OPTIONS:
+ {{range .Flags}}{{.}}
+ {{end}}{{end}}
+`
+}
+
// NewApp creates an app with sane defaults.
func NewApp(version, usage string) *cli.App {
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Author = ""
+ app.Authors = nil
app.Email = ""
app.Version = version
app.Usage = usage