From 5535f679870cfdd3d9ba14e51a3d48d6c037bb3f Mon Sep 17 00:00:00 2001 From: zaccoding Date: Tue, 26 Nov 2019 19:46:39 +0900 Subject: [PATCH] cmd: fix command help messages in modules (#20203) --- cmd/abigen/main.go | 15 +-------------- cmd/checkpoint-admin/main.go | 15 +-------------- cmd/clef/main.go | 1 + cmd/ethkey/main.go | 1 + cmd/evm/main.go | 1 + cmd/utils/flags.go | 11 +++++++++++ 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index 659cf1b4c537..252d8ef80002 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -32,19 +32,6 @@ import ( "gopkg.in/urfave/cli.v1" ) -const ( - commandHelperTemplate = `{{.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}}{{"\t"}}{{.}} -{{end}} -{{end}}` -) - var ( // Git SHA1 commit hash of the release (set via linker flags) gitCommit = "" @@ -128,7 +115,7 @@ func init() { aliasFlag, } app.Action = utils.MigrateFlags(abigen) - cli.CommandHelpTemplate = commandHelperTemplate + cli.CommandHelpTemplate = utils.OriginCommandHelpTemplate } func abigen(c *cli.Context) error { diff --git a/cmd/checkpoint-admin/main.go b/cmd/checkpoint-admin/main.go index 26d751dd81a6..b4d8e0db5acf 100644 --- a/cmd/checkpoint-admin/main.go +++ b/cmd/checkpoint-admin/main.go @@ -28,19 +28,6 @@ import ( "gopkg.in/urfave/cli.v1" ) -const ( - commandHelperTemplate = `{{.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}}{{"\t"}}{{.}} -{{end}} -{{end}}` -) - var ( // Git SHA1 commit hash of the release (set via linker flags) gitCommit = "" @@ -61,7 +48,7 @@ func init() { oracleFlag, nodeURLFlag, } - cli.CommandHelpTemplate = commandHelperTemplate + cli.CommandHelpTemplate = utils.OriginCommandHelpTemplate } // Commonly used command line flags. diff --git a/cmd/clef/main.go b/cmd/clef/main.go index 5775a1049fc0..b2c8812ab269 100644 --- a/cmd/clef/main.go +++ b/cmd/clef/main.go @@ -223,6 +223,7 @@ func init() { } app.Action = signer app.Commands = []cli.Command{initCommand, attestCommand, setCredentialCommand, delCredentialCommand, gendocCommand} + cli.CommandHelpTemplate = utils.OriginCommandHelpTemplate } func main() { diff --git a/cmd/ethkey/main.go b/cmd/ethkey/main.go index 5b545d5f946b..dbc49605888a 100644 --- a/cmd/ethkey/main.go +++ b/cmd/ethkey/main.go @@ -43,6 +43,7 @@ func init() { commandSignMessage, commandVerifyMessage, } + cli.CommandHelpTemplate = utils.OriginCommandHelpTemplate } // Commonly used command line flags. diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 5b8b950ab057..67447d58ae63 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -152,6 +152,7 @@ func init() { runCommand, stateTestCommand, } + cli.CommandHelpTemplate = utils.OriginCommandHelpTemplate } func main() { diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 4780a81373b1..c6846d312b00 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -77,6 +77,17 @@ SUBCOMMANDS: {{range $categorized.Flags}}{{"\t"}}{{.}} {{end}} {{end}}{{end}}` + + OriginCommandHelpTemplate = `{{.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}}{{"\t"}}{{.}} +{{end}} +{{end}}` ) func init() {