cmd/geth: improve command help messages (#3227)

This commit is contained in:
Kenji Siu 2016-11-10 19:00:09 +08:00 committed by Péter Szilágyi
parent dba29970d7
commit 80ea44c485
5 changed files with 132 additions and 87 deletions

View File

@ -31,30 +31,37 @@ import (
var ( var (
walletCommand = cli.Command{ walletCommand = cli.Command{
Name: "wallet", Name: "wallet",
Usage: "ethereum presale wallet", Usage: "Manage Ethereum presale wallets",
Subcommands: []cli.Command{ ArgsUsage: "",
{ Category: "ACCOUNT COMMANDS",
Action: importWallet,
Name: "import",
Usage: "import ethereum presale wallet",
},
},
Description: ` Description: `
geth wallet import /path/to/my/presale.wallet
get wallet import /path/to/my/presale.wallet
will prompt for your password and imports your ether presale account. will prompt for your password and imports your ether presale account.
It can be used non-interactively with the --password option taking a It can be used non-interactively with the --password option taking a
passwordfile as argument containing the wallet password in plaintext. passwordfile as argument containing the wallet password in plaintext.
`} `,
Subcommands: []cli.Command{
{
Action: importWallet,
Name: "import",
Usage: "Import Ethereum presale wallet",
ArgsUsage: "<keyFile>",
Description: `
TODO: Please write this
`,
},
},
}
accountCommand = cli.Command{ accountCommand = cli.Command{
Action: accountList, Action: accountList,
Name: "account", Name: "account",
Usage: "manage accounts", Usage: "Manage accounts",
ArgsUsage: "",
Category: "ACCOUNT COMMANDS",
Description: ` Description: `
Manage accounts lets you create new accounts, list all existing accounts, Manage accounts lets you create new accounts, list all existing accounts,
import a private key into a new account. import a private key into a new account.
@ -86,17 +93,21 @@ And finally. DO NOT FORGET YOUR PASSWORD.
`, `,
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Action: accountList, Action: accountList,
Name: "list", Name: "list",
Usage: "print account addresses", Usage: "Print account addresses",
ArgsUsage: " ",
Description: `
TODO: Please write this
`,
}, },
{ {
Action: accountCreate, Action: accountCreate,
Name: "new", Name: "new",
Usage: "create a new account", Usage: "Create a new account",
ArgsUsage: " ",
Description: ` Description: `
geth account new
ethereum account new
Creates a new account. Prints the address. Creates a new account. Prints the address.
@ -106,19 +117,19 @@ You must remember this passphrase to unlock your account in the future.
For non-interactive use the passphrase can be specified with the --password flag: For non-interactive use the passphrase can be specified with the --password flag:
ethereum --password <passwordfile> account new geth --password <passwordfile> account new
Note, this is meant to be used for testing only, it is a bad idea to save your Note, this is meant to be used for testing only, it is a bad idea to save your
password to file or expose in any other way. password to file or expose in any other way.
`, `,
}, },
{ {
Action: accountUpdate, Action: accountUpdate,
Name: "update", Name: "update",
Usage: "update an existing account", Usage: "Update an existing account",
ArgsUsage: "<address>",
Description: ` Description: `
geth account update <address>
ethereum account update <address>
Update an existing account. Update an existing account.
@ -130,19 +141,19 @@ format to the newest format or change the password for an account.
For non-interactive use the passphrase can be specified with the --password flag: For non-interactive use the passphrase can be specified with the --password flag:
ethereum --password <passwordfile> account update <address> geth --password <passwordfile> account update <address>
Since only one password can be given, only format update can be performed, Since only one password can be given, only format update can be performed,
changing your password is only possible interactively. changing your password is only possible interactively.
`, `,
}, },
{ {
Action: accountImport, Action: accountImport,
Name: "import", Name: "import",
Usage: "import a private key into a new account", Usage: "Import a private key into a new account",
ArgsUsage: "<keyFile>",
Description: ` Description: `
geth account import <keyfile>
ethereum account import <keyfile>
Imports an unencrypted private key from <keyfile> and creates a new account. Imports an unencrypted private key from <keyfile> and creates a new account.
Prints the address. Prints the address.
@ -155,13 +166,13 @@ You must remember this passphrase to unlock your account in the future.
For non-interactive use the passphrase can be specified with the -password flag: For non-interactive use the passphrase can be specified with the -password flag:
ethereum --password <passwordfile> account import <keyfile> geth --password <passwordfile> account import <keyfile>
Note: Note:
As you can directly copy your encrypted accounts to another ethereum instance, As you can directly copy your encrypted accounts to another ethereum instance,
this import mechanism is not needed when you transfer an account between this import mechanism is not needed when you transfer an account between
nodes. nodes.
`, `,
}, },
}, },
} }

View File

@ -40,35 +40,54 @@ import (
var ( var (
importCommand = cli.Command{ importCommand = cli.Command{
Action: importChain, Action: importChain,
Name: "import", Name: "import",
Usage: `import a blockchain file`, Usage: "Import a blockchain file",
ArgsUsage: "<filename>",
Category: "BLOCKCHAIN COMMANDS",
Description: `
TODO: Please write this
`,
} }
exportCommand = cli.Command{ exportCommand = cli.Command{
Action: exportChain, Action: exportChain,
Name: "export", Name: "export",
Usage: `export blockchain into file`, Usage: "Export blockchain into file",
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
Category: "BLOCKCHAIN COMMANDS",
Description: ` Description: `
Requires a first argument of the file to write to. Requires a first argument of the file to write to.
Optional second and third arguments control the first and Optional second and third arguments control the first and
last block to write. In this mode, the file will be appended last block to write. In this mode, the file will be appended
if already existing. if already existing.
`, `,
} }
upgradedbCommand = cli.Command{ upgradedbCommand = cli.Command{
Action: upgradeDB, Action: upgradeDB,
Name: "upgradedb", Name: "upgradedb",
Usage: "upgrade chainblock database", Usage: "Upgrade chainblock database",
ArgsUsage: " ",
Category: "BLOCKCHAIN COMMANDS",
Description: `
TODO: Please write this
`,
} }
removedbCommand = cli.Command{ removedbCommand = cli.Command{
Action: removeDB, Action: removeDB,
Name: "removedb", Name: "removedb",
Usage: "Remove blockchain and state databases", Usage: "Remove blockchain and state databases",
ArgsUsage: " ",
Category: "BLOCKCHAIN COMMANDS",
Description: `
TODO: Please write this
`,
} }
dumpCommand = cli.Command{ dumpCommand = cli.Command{
Action: dump, Action: dump,
Name: "dump", Name: "dump",
Usage: `dump a specific block from storage`, Usage: "Dump a specific block from storage",
ArgsUsage: "[<blockHash> | <blockNum>]...",
Category: "BLOCKCHAIN COMMANDS",
Description: ` Description: `
The arguments are interpreted as block numbers or hashes. The arguments are interpreted as block numbers or hashes.
Use "ethereum dump 0" to dump the genesis block. Use "ethereum dump 0" to dump the genesis block.

View File

@ -30,9 +30,11 @@ import (
var ( var (
consoleCommand = cli.Command{ consoleCommand = cli.Command{
Action: localConsole, Action: localConsole,
Name: "console", Name: "console",
Usage: `Geth Console: interactive JavaScript environment`, Usage: "Start an interactive JavaScript environment",
ArgsUsage: "", // TODO: Write this!
Category: "CONSOLE COMMANDS",
Description: ` Description: `
The Geth console is an interactive shell for the JavaScript runtime environment The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API. which exposes a node admin interface as well as the Ðapp JavaScript API.
@ -40,20 +42,24 @@ See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console
`, `,
} }
attachCommand = cli.Command{ attachCommand = cli.Command{
Action: remoteConsole, Action: remoteConsole,
Name: "attach", Name: "attach",
Usage: `Geth Console: interactive JavaScript environment (connect to node)`, Usage: "Start an interactive JavaScript environment (connect to node)",
ArgsUsage: "", // TODO: Write this!
Category: "CONSOLE COMMANDS",
Description: ` Description: `
The Geth console is an interactive shell for the JavaScript runtime environment The Geth console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API. which exposes a node admin interface as well as the Ðapp JavaScript API.
See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.
This command allows to open a console on a running geth node. This command allows to open a console on a running geth node.
`, `,
} }
javascriptCommand = cli.Command{ javascriptCommand = cli.Command{
Action: ephemeralConsole, Action: ephemeralConsole,
Name: "js", Name: "js",
Usage: `executes the given JavaScript files in the Geth JavaScript VM`, Usage: "Execute the specified JavaScript files",
ArgsUsage: "", // TODO: Write this!
Category: "CONSOLE COMMANDS",
Description: ` Description: `
The JavaScript VM exposes a node admin interface as well as the Ðapp The JavaScript VM exposes a node admin interface as well as the Ðapp
JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console

View File

@ -61,6 +61,7 @@ func init() {
// Initialize the CLI app and start Geth // Initialize the CLI app and start Geth
app.Action = geth app.Action = geth
app.HideVersion = true // we have a command to print the version app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2013-2016 The go-ethereum Authors"
app.Commands = []cli.Command{ app.Commands = []cli.Command{
importCommand, importCommand,
exportCommand, exportCommand,
@ -74,9 +75,11 @@ func init() {
attachCommand, attachCommand,
javascriptCommand, javascriptCommand,
{ {
Action: makedag, Action: makedag,
Name: "makedag", Name: "makedag",
Usage: "generate ethash dag (for testing)", Usage: "Generate ethash DAG (for testing)",
ArgsUsage: "<blockNum> <outputDir>",
Category: "MISCELLANEOUS COMMANDS",
Description: ` Description: `
The makedag command generates an ethash DAG in /tmp/dag. The makedag command generates an ethash DAG in /tmp/dag.
@ -85,27 +88,33 @@ Regular users do not need to execute it.
`, `,
}, },
{ {
Action: version, Action: version,
Name: "version", Name: "version",
Usage: "print ethereum version numbers", Usage: "Print version numbers",
ArgsUsage: " ",
Category: "MISCELLANEOUS COMMANDS",
Description: ` Description: `
The output of this command is supposed to be machine-readable. The output of this command is supposed to be machine-readable.
`, `,
}, },
{ {
Action: initGenesis, Action: initGenesis,
Name: "init", Name: "init",
Usage: "bootstraps and initialises a new genesis block (JSON)", Usage: "Bootstrap and initialize a new genesis block",
ArgsUsage: "<genesisPath>",
Category: "BLOCKCHAIN COMMANDS",
Description: ` Description: `
The init command initialises a new genesis block and definition for the network. The init command initializes a new genesis block and definition for the network.
This is a destructive action and changes the network in which you will be This is a destructive action and changes the network in which you will be
participating. participating.
`, `,
}, },
{ {
Action: license, Action: license,
Name: "license", Name: "license",
Usage: "displays geth's license information", Usage: "Display license information",
ArgsUsage: " ",
Category: "MISCELLANEOUS COMMANDS",
}, },
} }
@ -335,23 +344,22 @@ func makedag(ctx *cli.Context) error {
return nil return nil
} }
func version(c *cli.Context) error { func version(ctx *cli.Context) error {
fmt.Println(strings.Title(clientIdentifier)) fmt.Println(strings.Title(clientIdentifier))
fmt.Println("Version:", utils.Version) fmt.Println("Version:", utils.Version)
if gitCommit != "" { if gitCommit != "" {
fmt.Println("Git Commit:", gitCommit) fmt.Println("Git Commit:", gitCommit)
} }
fmt.Println("Protocol Versions:", eth.ProtocolVersions) fmt.Println("Protocol Versions:", eth.ProtocolVersions)
fmt.Println("Network Id:", c.GlobalInt(utils.NetworkIdFlag.Name)) fmt.Println("Network Id:", ctx.GlobalInt(utils.NetworkIdFlag.Name))
fmt.Println("Go Version:", runtime.Version()) fmt.Println("Go Version:", runtime.Version())
fmt.Println("OS:", runtime.GOOS) fmt.Println("OS:", runtime.GOOS)
fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
return nil return nil
} }
func license(c *cli.Context) error { func license(_ *cli.Context) error {
fmt.Println(`Geth is free software: you can redistribute it and/or modify fmt.Println(`Geth is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
@ -365,6 +373,5 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with geth. If not, see <http://www.gnu.org/licenses/>. along with geth. If not, see <http://www.gnu.org/licenses/>.
`) `)
return nil return nil
} }

View File

@ -49,9 +49,11 @@ var (
Usage: "Refresh interval in seconds", Usage: "Refresh interval in seconds",
} }
monitorCommand = cli.Command{ monitorCommand = cli.Command{
Action: monitor, Action: monitor,
Name: "monitor", Name: "monitor",
Usage: `Geth Monitor: node metrics monitoring and visualization`, Usage: "Monitor and visualize node metrics",
ArgsUsage: " ",
Category: "MONITOR COMMANDS",
Description: ` Description: `
The Geth monitor is a tool to collect and visualize various internal metrics The Geth monitor is a tool to collect and visualize various internal metrics
gathered by the node, supporting different chart types as well as the capacity gathered by the node, supporting different chart types as well as the capacity