Skip to content

Commit 80ea44c

Browse files
kenji-isuntvkaralabe
authored andcommitted
cmd/geth: improve command help messages (bnb-chain#3227)
1 parent dba2997 commit 80ea44c

5 files changed

Lines changed: 132 additions & 87 deletions

File tree

‎cmd/geth/accountcmd.go‎

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,37 @@ import (
3131

3232
var (
3333
walletCommand = cli.Command{
34-
Name: "wallet",
35-
Usage: "ethereum presale wallet",
36-
Subcommands: []cli.Command{
37-
{
38-
Action: importWallet,
39-
Name: "import",
40-
Usage: "import ethereum presale wallet",
41-
},
42-
},
34+
Name: "wallet",
35+
Usage: "Manage Ethereum presale wallets",
36+
ArgsUsage: "",
37+
Category: "ACCOUNT COMMANDS",
4338
Description: `
44-
45-
get wallet import /path/to/my/presale.wallet
39+
geth wallet import /path/to/my/presale.wallet
4640
4741
will prompt for your password and imports your ether presale account.
4842
It can be used non-interactively with the --password option taking a
4943
passwordfile as argument containing the wallet password in plaintext.
5044
51-
`}
45+
`,
46+
Subcommands: []cli.Command{
47+
{
48+
Action: importWallet,
49+
Name: "import",
50+
Usage: "Import Ethereum presale wallet",
51+
ArgsUsage: "<keyFile>",
52+
Description: `
53+
TODO: Please write this
54+
`,
55+
},
56+
},
57+
}
5258
accountCommand = cli.Command{
53-
Action: accountList,
54-
Name: "account",
55-
Usage: "manage accounts",
59+
Action: accountList,
60+
Name: "account",
61+
Usage: "Manage accounts",
62+
ArgsUsage: "",
63+
Category: "ACCOUNT COMMANDS",
5664
Description: `
57-
5865
Manage accounts lets you create new accounts, list all existing accounts,
5966
import a private key into a new account.
6067
@@ -86,17 +93,21 @@ And finally. DO NOT FORGET YOUR PASSWORD.
8693
`,
8794
Subcommands: []cli.Command{
8895
{
89-
Action: accountList,
90-
Name: "list",
91-
Usage: "print account addresses",
96+
Action: accountList,
97+
Name: "list",
98+
Usage: "Print account addresses",
99+
ArgsUsage: " ",
100+
Description: `
101+
TODO: Please write this
102+
`,
92103
},
93104
{
94-
Action: accountCreate,
95-
Name: "new",
96-
Usage: "create a new account",
105+
Action: accountCreate,
106+
Name: "new",
107+
Usage: "Create a new account",
108+
ArgsUsage: " ",
97109
Description: `
98-
99-
ethereum account new
110+
geth account new
100111
101112
Creates a new account. Prints the address.
102113
@@ -106,19 +117,19 @@ You must remember this passphrase to unlock your account in the future.
106117
107118
For non-interactive use the passphrase can be specified with the --password flag:
108119
109-
ethereum --password <passwordfile> account new
120+
geth --password <passwordfile> account new
110121
111122
Note, this is meant to be used for testing only, it is a bad idea to save your
112123
password to file or expose in any other way.
113-
`,
124+
`,
114125
},
115126
{
116-
Action: accountUpdate,
117-
Name: "update",
118-
Usage: "update an existing account",
127+
Action: accountUpdate,
128+
Name: "update",
129+
Usage: "Update an existing account",
130+
ArgsUsage: "<address>",
119131
Description: `
120-
121-
ethereum account update <address>
132+
geth account update <address>
122133
123134
Update an existing account.
124135
@@ -130,19 +141,19 @@ format to the newest format or change the password for an account.
130141
131142
For non-interactive use the passphrase can be specified with the --password flag:
132143
133-
ethereum --password <passwordfile> account update <address>
144+
geth --password <passwordfile> account update <address>
134145
135146
Since only one password can be given, only format update can be performed,
136147
changing your password is only possible interactively.
137-
`,
148+
`,
138149
},
139150
{
140-
Action: accountImport,
141-
Name: "import",
142-
Usage: "import a private key into a new account",
151+
Action: accountImport,
152+
Name: "import",
153+
Usage: "Import a private key into a new account",
154+
ArgsUsage: "<keyFile>",
143155
Description: `
144-
145-
ethereum account import <keyfile>
156+
geth account import <keyfile>
146157
147158
Imports an unencrypted private key from <keyfile> and creates a new account.
148159
Prints the address.
@@ -155,13 +166,13 @@ You must remember this passphrase to unlock your account in the future.
155166
156167
For non-interactive use the passphrase can be specified with the -password flag:
157168
158-
ethereum --password <passwordfile> account import <keyfile>
169+
geth --password <passwordfile> account import <keyfile>
159170
160171
Note:
161172
As you can directly copy your encrypted accounts to another ethereum instance,
162173
this import mechanism is not needed when you transfer an account between
163174
nodes.
164-
`,
175+
`,
165176
},
166177
},
167178
}

‎cmd/geth/chaincmd.go‎

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,54 @@ import (
4040

4141
var (
4242
importCommand = cli.Command{
43-
Action: importChain,
44-
Name: "import",
45-
Usage: `import a blockchain file`,
43+
Action: importChain,
44+
Name: "import",
45+
Usage: "Import a blockchain file",
46+
ArgsUsage: "<filename>",
47+
Category: "BLOCKCHAIN COMMANDS",
48+
Description: `
49+
TODO: Please write this
50+
`,
4651
}
4752
exportCommand = cli.Command{
48-
Action: exportChain,
49-
Name: "export",
50-
Usage: `export blockchain into file`,
53+
Action: exportChain,
54+
Name: "export",
55+
Usage: "Export blockchain into file",
56+
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
57+
Category: "BLOCKCHAIN COMMANDS",
5158
Description: `
5259
Requires a first argument of the file to write to.
5360
Optional second and third arguments control the first and
5461
last block to write. In this mode, the file will be appended
5562
if already existing.
56-
`,
63+
`,
5764
}
5865
upgradedbCommand = cli.Command{
59-
Action: upgradeDB,
60-
Name: "upgradedb",
61-
Usage: "upgrade chainblock database",
66+
Action: upgradeDB,
67+
Name: "upgradedb",
68+
Usage: "Upgrade chainblock database",
69+
ArgsUsage: " ",
70+
Category: "BLOCKCHAIN COMMANDS",
71+
Description: `
72+
TODO: Please write this
73+
`,
6274
}
6375
removedbCommand = cli.Command{
64-
Action: removeDB,
65-
Name: "removedb",
66-
Usage: "Remove blockchain and state databases",
76+
Action: removeDB,
77+
Name: "removedb",
78+
Usage: "Remove blockchain and state databases",
79+
ArgsUsage: " ",
80+
Category: "BLOCKCHAIN COMMANDS",
81+
Description: `
82+
TODO: Please write this
83+
`,
6784
}
6885
dumpCommand = cli.Command{
69-
Action: dump,
70-
Name: "dump",
71-
Usage: `dump a specific block from storage`,
86+
Action: dump,
87+
Name: "dump",
88+
Usage: "Dump a specific block from storage",
89+
ArgsUsage: "[<blockHash> | <blockNum>]...",
90+
Category: "BLOCKCHAIN COMMANDS",
7291
Description: `
7392
The arguments are interpreted as block numbers or hashes.
7493
Use "ethereum dump 0" to dump the genesis block.

‎cmd/geth/consolecmd.go‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,36 @@ import (
3030

3131
var (
3232
consoleCommand = cli.Command{
33-
Action: localConsole,
34-
Name: "console",
35-
Usage: `Geth Console: interactive JavaScript environment`,
33+
Action: localConsole,
34+
Name: "console",
35+
Usage: "Start an interactive JavaScript environment",
36+
ArgsUsage: "", // TODO: Write this!
37+
Category: "CONSOLE COMMANDS",
3638
Description: `
3739
The Geth console is an interactive shell for the JavaScript runtime environment
3840
which exposes a node admin interface as well as the Ðapp JavaScript API.
3941
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console
4042
`,
4143
}
4244
attachCommand = cli.Command{
43-
Action: remoteConsole,
44-
Name: "attach",
45-
Usage: `Geth Console: interactive JavaScript environment (connect to node)`,
45+
Action: remoteConsole,
46+
Name: "attach",
47+
Usage: "Start an interactive JavaScript environment (connect to node)",
48+
ArgsUsage: "", // TODO: Write this!
49+
Category: "CONSOLE COMMANDS",
4650
Description: `
4751
The Geth console is an interactive shell for the JavaScript runtime environment
4852
which exposes a node admin interface as well as the Ðapp JavaScript API.
4953
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.
5054
This command allows to open a console on a running geth node.
51-
`,
55+
`,
5256
}
5357
javascriptCommand = cli.Command{
54-
Action: ephemeralConsole,
55-
Name: "js",
56-
Usage: `executes the given JavaScript files in the Geth JavaScript VM`,
58+
Action: ephemeralConsole,
59+
Name: "js",
60+
Usage: "Execute the specified JavaScript files",
61+
ArgsUsage: "", // TODO: Write this!
62+
Category: "CONSOLE COMMANDS",
5763
Description: `
5864
The JavaScript VM exposes a node admin interface as well as the Ðapp
5965
JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console

‎cmd/geth/main.go‎

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func init() {
6161
// Initialize the CLI app and start Geth
6262
app.Action = geth
6363
app.HideVersion = true // we have a command to print the version
64+
app.Copyright = "Copyright 2013-2016 The go-ethereum Authors"
6465
app.Commands = []cli.Command{
6566
importCommand,
6667
exportCommand,
@@ -74,9 +75,11 @@ func init() {
7475
attachCommand,
7576
javascriptCommand,
7677
{
77-
Action: makedag,
78-
Name: "makedag",
79-
Usage: "generate ethash dag (for testing)",
78+
Action: makedag,
79+
Name: "makedag",
80+
Usage: "Generate ethash DAG (for testing)",
81+
ArgsUsage: "<blockNum> <outputDir>",
82+
Category: "MISCELLANEOUS COMMANDS",
8083
Description: `
8184
The makedag command generates an ethash DAG in /tmp/dag.
8285
@@ -85,27 +88,33 @@ Regular users do not need to execute it.
8588
`,
8689
},
8790
{
88-
Action: version,
89-
Name: "version",
90-
Usage: "print ethereum version numbers",
91+
Action: version,
92+
Name: "version",
93+
Usage: "Print version numbers",
94+
ArgsUsage: " ",
95+
Category: "MISCELLANEOUS COMMANDS",
9196
Description: `
9297
The output of this command is supposed to be machine-readable.
9398
`,
9499
},
95100
{
96-
Action: initGenesis,
97-
Name: "init",
98-
Usage: "bootstraps and initialises a new genesis block (JSON)",
101+
Action: initGenesis,
102+
Name: "init",
103+
Usage: "Bootstrap and initialize a new genesis block",
104+
ArgsUsage: "<genesisPath>",
105+
Category: "BLOCKCHAIN COMMANDS",
99106
Description: `
100-
The init command initialises a new genesis block and definition for the network.
107+
The init command initializes a new genesis block and definition for the network.
101108
This is a destructive action and changes the network in which you will be
102109
participating.
103110
`,
104111
},
105112
{
106-
Action: license,
107-
Name: "license",
108-
Usage: "displays geth's license information",
113+
Action: license,
114+
Name: "license",
115+
Usage: "Display license information",
116+
ArgsUsage: " ",
117+
Category: "MISCELLANEOUS COMMANDS",
109118
},
110119
}
111120

@@ -335,23 +344,22 @@ func makedag(ctx *cli.Context) error {
335344
return nil
336345
}
337346

338-
func version(c *cli.Context) error {
347+
func version(ctx *cli.Context) error {
339348
fmt.Println(strings.Title(clientIdentifier))
340349
fmt.Println("Version:", utils.Version)
341350
if gitCommit != "" {
342351
fmt.Println("Git Commit:", gitCommit)
343352
}
344353
fmt.Println("Protocol Versions:", eth.ProtocolVersions)
345-
fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name))
354+
fmt.Println("Network Id:", ctx.GlobalInt(utils.NetworkIdFlag.Name))
346355
fmt.Println("Go Version:", runtime.Version())
347356
fmt.Println("OS:", runtime.GOOS)
348357
fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
349358
fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
350-
351359
return nil
352360
}
353361

354-
func license(c *cli.Context) error {
362+
func license(_ *cli.Context) error {
355363
fmt.Println(`Geth is free software: you can redistribute it and/or modify
356364
it under the terms of the GNU General Public License as published by
357365
the Free Software Foundation, either version 3 of the License, or
@@ -365,6 +373,5 @@ GNU General Public License for more details.
365373
You should have received a copy of the GNU General Public License
366374
along with geth. If not, see <http://www.gnu.org/licenses/>.
367375
`)
368-
369376
return nil
370377
}

‎cmd/geth/monitorcmd.go‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ var (
4949
Usage: "Refresh interval in seconds",
5050
}
5151
monitorCommand = cli.Command{
52-
Action: monitor,
53-
Name: "monitor",
54-
Usage: `Geth Monitor: node metrics monitoring and visualization`,
52+
Action: monitor,
53+
Name: "monitor",
54+
Usage: "Monitor and visualize node metrics",
55+
ArgsUsage: " ",
56+
Category: "MONITOR COMMANDS",
5557
Description: `
5658
The Geth monitor is a tool to collect and visualize various internal metrics
5759
gathered by the node, supporting different chart types as well as the capacity

0 commit comments

Comments
 (0)