quorum/cmd/geth/usage.go

386 lines
9.4 KiB
Go
Raw Normal View History

// Copyright 2015 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// Contains the geth command usage template and generator.
package main
import (
"io"
"sort"
2018-05-23 22:32:26 -07:00
"strings"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/internal/debug"
"gopkg.in/urfave/cli.v1"
)
// AppHelpTemplate is the test template for the default, global app help topic.
var AppHelpTemplate = `NAME:
{{.App.Name}} - {{.App.Usage}}
2018-05-23 22:32:26 -07:00
Copyright 2013-2018 The go-ethereum Authors
USAGE:
{{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}}
{{if .App.Version}}
VERSION:
{{.App.Version}}
{{end}}{{if len .App.Authors}}
AUTHOR(S):
{{range .App.Authors}}{{ . }}{{end}}
{{end}}{{if .App.Commands}}
COMMANDS:
{{range .App.Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}{{end}}{{if .FlagGroups}}
{{range .FlagGroups}}{{.Name}} OPTIONS:
{{range .Flags}}{{.}}
{{end}}
{{end}}{{end}}{{if .App.Copyright }}
COPYRIGHT:
{{.App.Copyright}}
{{end}}
`
// flagGroup is a collection of flags belonging to a single topic.
type flagGroup struct {
Name string
Flags []cli.Flag
}
// AppHelpFlagGroups is the application flags, grouped by functionality.
var AppHelpFlagGroups = []flagGroup{
{
Name: "ETHEREUM",
Flags: []cli.Flag{
configFileFlag,
utils.DataDirFlag,
2016-03-07 14:38:56 -08:00
utils.KeyStoreDirFlag,
utils.NoUSBFlag,
utils.NetworkIdFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
utils.OttomanFlag,
utils.SyncModeFlag,
2018-05-23 22:32:26 -07:00
utils.GCModeFlag,
utils.EthStatsURLFlag,
utils.IdentityFlag,
utils.LightServFlag,
utils.LightPeersFlag,
utils.LightKDFFlag,
},
},
{
Name: "DEVELOPER CHAIN",
2018-05-23 22:32:26 -07:00
Flags: []cli.Flag{
utils.DeveloperFlag,
utils.DeveloperPeriodFlag,
},
},
{
Name: "ETHASH",
Flags: []cli.Flag{
utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag,
utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag,
},
},
//{
// Name: "DASHBOARD",
// Flags: []cli.Flag{
// utils.DashboardEnabledFlag,
// utils.DashboardAddrFlag,
// utils.DashboardPortFlag,
// utils.DashboardRefreshFlag,
// utils.DashboardAssetsFlag,
// },
//},
{
Name: "TRANSACTION POOL",
Flags: []cli.Flag{
utils.TxPoolLocalsFlag,
2018-05-23 22:32:26 -07:00
utils.TxPoolNoLocalsFlag,
utils.TxPoolJournalFlag,
utils.TxPoolRejournalFlag,
utils.TxPoolPriceLimitFlag,
utils.TxPoolPriceBumpFlag,
utils.TxPoolAccountSlotsFlag,
utils.TxPoolGlobalSlotsFlag,
utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag,
utils.TxPoolLifetimeFlag,
},
},
{
Name: "ETHASH",
Flags: []cli.Flag{
utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag,
utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag,
},
},
{
Name: "PERFORMANCE TUNING",
Flags: []cli.Flag{
utils.CacheFlag,
2018-05-23 22:32:26 -07:00
utils.CacheDatabaseFlag,
utils.CacheGCFlag,
utils.TrieCacheGenFlag,
},
},
2016-10-09 08:10:48 -07:00
{
Name: "QUORUM",
2016-10-09 08:10:48 -07:00
Flags: []cli.Flag{
utils.EnableNodePermissionFlag,
2016-10-09 08:10:48 -07:00
},
},
2017-08-28 14:43:44 -07:00
{
Name: "RAFT",
Flags: []cli.Flag{
utils.RaftModeFlag,
utils.RaftBlockTimeFlag,
utils.RaftJoinExistingFlag,
utils.RaftPortFlag,
},
},
{
Name: "ACCOUNT",
Flags: []cli.Flag{
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
},
},
{
Name: "API AND CONSOLE",
Flags: []cli.Flag{
utils.RPCEnabledFlag,
utils.RPCListenAddrFlag,
utils.RPCPortFlag,
utils.RPCApiFlag,
utils.WSEnabledFlag,
utils.WSListenAddrFlag,
utils.WSPortFlag,
utils.WSApiFlag,
utils.WSAllowedOriginsFlag,
utils.IPCDisabledFlag,
utils.IPCPathFlag,
utils.RPCCORSDomainFlag,
2018-05-23 22:32:26 -07:00
utils.RPCVirtualHostsFlag,
utils.JSpathFlag,
utils.ExecFlag,
utils.PreloadJSFlag,
},
},
{
Name: "NETWORKING",
Flags: []cli.Flag{
utils.BootnodesFlag,
utils.BootnodesV4Flag,
utils.BootnodesV5Flag,
utils.ListenPortFlag,
utils.MaxPeersFlag,
utils.MaxPendingPeersFlag,
utils.NATFlag,
utils.NoDiscoverFlag,
utils.DiscoveryV5Flag,
utils.NetrestrictFlag,
utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag,
},
},
{
Name: "MINER",
Flags: []cli.Flag{
utils.MiningEnabledFlag,
utils.MinerThreadsFlag,
utils.MinerNotifyFlag,
utils.MinerGasPriceFlag,
utils.MinerGasTargetFlag,
utils.MinerGasLimitFlag,
utils.MinerEtherbaseFlag,
utils.MinerExtraDataFlag,
utils.MinerRecommitIntervalFlag,
utils.MinerNoVerfiyFlag,
},
},
{
Name: "GAS PRICE ORACLE",
Flags: []cli.Flag{
utils.GpoBlocksFlag,
utils.GpoPercentileFlag,
},
},
{
Name: "VIRTUAL MACHINE",
Flags: []cli.Flag{
utils.VMEnableDebugFlag,
utils.EVMInterpreterFlag,
utils.EWASMInterpreterFlag,
},
},
{
Name: "LOGGING AND DEBUGGING",
Flags: append([]cli.Flag{
utils.FakePoWFlag,
utils.NoCompactionFlag,
}, debug.Flags...),
},
{
Name: "METRICS AND STATS",
Flags: []cli.Flag{
utils.MetricsEnabledFlag,
utils.MetricsEnableInfluxDBFlag,
utils.MetricsInfluxDBEndpointFlag,
utils.MetricsInfluxDBDatabaseFlag,
utils.MetricsInfluxDBUsernameFlag,
utils.MetricsInfluxDBPasswordFlag,
utils.MetricsInfluxDBHostTagFlag,
},
},
{
Name: "WHISPER (EXPERIMENTAL)",
Flags: whisperFlags,
},
{
Name: "DEPRECATED",
Flags: []cli.Flag{
utils.MinerLegacyThreadsFlag,
utils.MinerLegacyGasTargetFlag,
utils.MinerLegacyGasPriceFlag,
utils.MinerLegacyEtherbaseFlag,
utils.MinerLegacyExtraDataFlag,
},
},
{
Name: "MISC",
Merge remote-tracking branch 'remotes/geth/release/1.8' into merge-193 # Conflicts: # .github/CODEOWNERS # .travis.yml # README.md # VERSION # accounts/abi/argument.go # accounts/abi/bind/backends/simulated.go # accounts/abi/bind/bind_test.go # accounts/abi/event_test.go # accounts/abi/numbers.go # accounts/abi/numbers_test.go # accounts/abi/reflect.go # accounts/accounts.go # accounts/keystore/keystore.go # accounts/keystore/keystore_wallet.go # accounts/usbwallet/internal/trezor/trezor.go # accounts/usbwallet/ledger.go # accounts/usbwallet/wallet.go # appveyor.yml # build/ci.go # build/goimports.sh # cmd/ethkey/generate.go # cmd/ethkey/inspect.go # cmd/ethkey/main.go # cmd/ethkey/message.go # cmd/ethkey/utils.go # cmd/faucet/faucet.go # cmd/geth/chaincmd.go # cmd/geth/config.go # cmd/geth/main.go # cmd/geth/misccmd.go # cmd/geth/usage.go # cmd/p2psim/main.go # cmd/puppeth/genesis.go # cmd/puppeth/module_dashboard.go # cmd/puppeth/wizard_faucet.go # cmd/puppeth/wizard_genesis.go # cmd/puppeth/wizard_netstats.go # cmd/puppeth/wizard_node.go # cmd/puppeth/wizard_wallet.go # cmd/swarm/config.go # cmd/swarm/config_test.go # cmd/swarm/db.go # cmd/swarm/hash.go # cmd/swarm/main.go # cmd/swarm/manifest.go # cmd/swarm/run_test.go # cmd/swarm/upload.go # cmd/swarm/upload_test.go # cmd/utils/flags.go # cmd/wnode/main.go # common/bytes.go # common/compiler/solidity.go # common/hexutil/hexutil.go # common/math/big.go # common/math/integer.go # common/mclock/mclock.go # common/types.go # common/types_template.go # consensus/clique/clique.go # consensus/consensus.go # consensus/ethash/algorithm.go # consensus/ethash/consensus.go # consensus/ethash/ethash.go # containers/vagrant/Vagrantfile # contracts/ens/ens_test.go # core/asm/compiler.go # core/asm/lexer.go # core/block_validator.go # core/blockchain.go # core/blockchain_test.go # core/chain_makers.go # core/database_util.go # core/database_util_test.go # core/events.go # core/genesis.go # core/genesis_alloc.go # core/genesis_test.go # core/headerchain.go # core/rawdb/accessors_chain.go # core/rawdb/accessors_indexes.go # core/rawdb/accessors_metadata.go # core/rawdb/schema.go # core/state/state_test.go # core/state/statedb.go # core/state/sync.go # core/state_processor.go # core/state_transition.go # core/tx_journal.go # core/tx_list.go # core/tx_pool.go # core/tx_pool_test.go # core/types.go # core/types/block.go # core/types/block_test.go # core/types/gen_receipt_json.go # core/types/log.go # core/types/receipt.go # core/types/transaction.go # core/types/transaction_signing.go # core/types/transaction_signing_test.go # core/types/transaction_test.go # core/vm/errors.go # core/vm/evm.go # core/vm/gas.go # core/vm/gas_table.go # core/vm/instructions.go # core/vm/instructions_test.go # core/vm/interface.go # core/vm/interpreter.go # core/vm/intpool.go # core/vm/jump_table.go # core/vm/logger.go # core/vm/logger_test.go # core/vm/memory_table.go # core/vm/opcodes.go # core/vm/runtime/env.go # core/vm/runtime/runtime.go # crypto/crypto.go # crypto/crypto_test.go # eth/api.go # eth/api_backend.go # eth/api_tracer.go # eth/backend.go # eth/config.go # eth/downloader/downloader.go # eth/downloader/queue.go # eth/downloader/statesync.go # eth/filters/filter.go # eth/filters/filter_system.go # eth/filters/filter_system_test.go # eth/gen_config.go # eth/handler.go # eth/handler_test.go # eth/helper_test.go # eth/protocol.go # eth/sync.go # eth/tracers/internal/tracers/4byte_tracer.js # eth/tracers/internal/tracers/assets.go # eth/tracers/tracer_test.go # eth/tracers/tracers_test.go # ethclient/ethclient.go # ethdb/database.go # ethdb/interface.go # ethdb/memory_database.go # ethstats/ethstats.go # event/feed.go # internal/ethapi/api.go # internal/ethapi/backend.go # internal/guide/guide_test.go # internal/web3ext/web3ext.go # les/api_backend.go # les/backend.go # les/fetcher.go # les/handler.go # les/helper_test.go # les/odr_requests.go # les/odr_test.go # les/retrieve.go # les/server.go # les/serverpool.go # light/lightchain.go # light/odr_test.go # light/postprocess.go # light/txpool.go # log/README.md # log/doc.go # log/format.go # log/handler.go # log/logger.go # log/root.go # metrics/exp/exp.go # metrics/influxdb/influxdb.go # metrics/metrics.go # metrics/resetting_timer.go # metrics/resetting_timer_test.go # metrics/timer_test.go # miner/worker.go # mobile/accounts.go # mobile/ethereum.go # mobile/geth.go # node/config.go # node/doc.go # p2p/discover/database.go # p2p/discover/database_test.go # p2p/discover/table.go # p2p/discover/table_test.go # p2p/discover/udp.go # p2p/discover/udp_test.go # p2p/discv5/udp.go # p2p/enr/enr.go # p2p/enr/enr_test.go # p2p/enr/entries.go # p2p/protocols/protocol.go # p2p/protocols/protocol_test.go # p2p/rlpx_test.go # p2p/server.go # p2p/simulations/adapters/docker.go # p2p/simulations/adapters/exec.go # p2p/simulations/adapters/inproc.go # p2p/simulations/adapters/types.go # p2p/simulations/http.go # p2p/simulations/http_test.go # p2p/simulations/mocker.go # p2p/simulations/network.go # p2p/simulations/network_test.go # p2p/testing/protocolsession.go # params/bootnodes.go # params/config.go # params/denomination.go # params/gas_table.go # params/protocol_params.go # params/version.go # rpc/http.go # rpc/json.go # rpc/utils.go # signer/core/api.go # swarm/api/api.go # swarm/api/api_test.go # swarm/api/client/client.go # swarm/api/client/client_test.go # swarm/api/config.go # swarm/api/config_test.go # swarm/api/filesystem.go # swarm/api/filesystem_test.go # swarm/api/http/error.go # swarm/api/http/error_templates.go # swarm/api/http/error_test.go # swarm/api/http/roundtripper.go # swarm/api/http/server.go # swarm/api/http/server_test.go # swarm/api/http/templates.go # swarm/api/manifest.go # swarm/api/manifest_test.go # swarm/api/storage.go # swarm/api/storage_test.go # swarm/api/uri.go # swarm/api/uri_test.go # swarm/fuse/fuse_dir.go # swarm/fuse/fuse_file.go # swarm/fuse/swarmfs.go # swarm/fuse/swarmfs_test.go # swarm/fuse/swarmfs_unix.go # swarm/fuse/swarmfs_util.go # swarm/metrics/flags.go # swarm/network/depo.go # swarm/network/forwarding.go # swarm/network/hive.go # swarm/network/kademlia/address.go # swarm/network/kademlia/kaddb.go # swarm/network/kademlia/kademlia.go # swarm/network/kademlia/kademlia_test.go # swarm/network/messages.go # swarm/network/protocol.go # swarm/network/syncdb.go # swarm/network/syncdb_test.go # swarm/network/syncer.go # swarm/services/swap/swap.go # swarm/services/swap/swap/swap.go # swarm/storage/chunker.go # swarm/storage/chunker_test.go # swarm/storage/common_test.go # swarm/storage/database.go # swarm/storage/dbstore.go # swarm/storage/dbstore_test.go # swarm/storage/dpa.go # swarm/storage/dpa_test.go # swarm/storage/localstore.go # swarm/storage/memstore.go # swarm/storage/netstore.go # swarm/storage/pyramid.go # swarm/storage/swarmhasher.go # swarm/storage/types.go # swarm/swarm.go # swarm/swarm_test.go # swarm/testutil/http.go # tests/block_test_util.go # tests/difficulty_test.go # tests/init.go # tests/state_test_util.go # tests/transaction_test.go # tests/util.go # tests/vm_test_util.go # trie/database.go # trie/encoding.go # trie/hasher.go # trie/iterator.go # trie/proof.go # trie/proof_test.go # trie/secure_trie.go # trie/sync.go # trie/sync_test.go # trie/trie.go # vendor/github.com/docker/docker/pkg/reexec/command_linux.go # vendor/github.com/docker/docker/pkg/reexec/command_unix.go # vendor/github.com/docker/docker/pkg/reexec/command_unsupported.go # vendor/github.com/docker/docker/pkg/reexec/command_windows.go # vendor/github.com/docker/docker/pkg/reexec/reexec.go # vendor/github.com/eapache/channels/.gitignore # vendor/github.com/eapache/queue/.gitignore # vendor/github.com/naoina/toml/encode.go # vendor/github.com/naoina/toml/parse.go # vendor/github.com/naoina/toml/parse.peg # vendor/github.com/naoina/toml/parse.peg.go # vendor/github.com/rcrowley/go-metrics/.gitignore # vendor/github.com/rcrowley/go-metrics/.travis.yml # vendor/github.com/rcrowley/go-metrics/README.md # vendor/github.com/rcrowley/go-metrics/counter.go # vendor/github.com/rcrowley/go-metrics/debug.go # vendor/github.com/rcrowley/go-metrics/ewma.go # vendor/github.com/rcrowley/go-metrics/exp/exp.go # vendor/github.com/rcrowley/go-metrics/gauge.go # vendor/github.com/rcrowley/go-metrics/gauge_float64.go # vendor/github.com/rcrowley/go-metrics/graphite.go # vendor/github.com/rcrowley/go-metrics/healthcheck.go # vendor/github.com/rcrowley/go-metrics/histogram.go # vendor/github.com/rcrowley/go-metrics/json.go # vendor/github.com/rcrowley/go-metrics/log.go # vendor/github.com/rcrowley/go-metrics/meter.go # vendor/github.com/rcrowley/go-metrics/metrics.go # vendor/github.com/rcrowley/go-metrics/opentsdb.go # vendor/github.com/rcrowley/go-metrics/registry.go # vendor/github.com/rcrowley/go-metrics/runtime.go # vendor/github.com/rcrowley/go-metrics/sample.go # vendor/github.com/rcrowley/go-metrics/syslog.go # vendor/github.com/rcrowley/go-metrics/timer.go # vendor/github.com/rcrowley/go-metrics/writer.go # vendor/github.com/syndtr/goleveldb/leveldb/db.go # vendor/golang.org/x/sys/unix/mksysnum_linux.pl # vendor/golang.org/x/sys/unix/types_linux.go # vendor/vendor.json # whisper/shhclient/client.go # whisper/whisperv5/api.go # whisper/whisperv5/peer_test.go # whisper/whisperv5/whisper.go # whisper/whisperv6/api.go # whisper/whisperv6/peer_test.go # whisper/whisperv6/whisper.go
2018-07-24 01:11:05 -07:00
},{
Name: "ISTANBUL",
Flags: []cli.Flag{
utils.IstanbulRequestTimeoutFlag,
utils.IstanbulBlockPeriodFlag,
},
},
2018-05-23 22:32:26 -07:00
}
// byCategory sorts an array of flagGroup by Name in the order
// defined in AppHelpFlagGroups.
type byCategory []flagGroup
func (a byCategory) Len() int { return len(a) }
func (a byCategory) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byCategory) Less(i, j int) bool {
iCat, jCat := a[i].Name, a[j].Name
iIdx, jIdx := len(AppHelpFlagGroups), len(AppHelpFlagGroups) // ensure non categorized flags come last
for i, group := range AppHelpFlagGroups {
if iCat == group.Name {
iIdx = i
}
if jCat == group.Name {
jIdx = i
}
}
return iIdx < jIdx
}
func flagCategory(flag cli.Flag) string {
for _, category := range AppHelpFlagGroups {
for _, flg := range category.Flags {
if flg.GetName() == flag.GetName() {
return category.Name
}
}
}
return "MISC"
}
func init() {
// Override the default app help template
cli.AppHelpTemplate = AppHelpTemplate
// Define a one shot struct to pass to the usage template
type helpData struct {
App interface{}
FlagGroups []flagGroup
}
// Override the default app help printer, but only for the global app help
originalHelpPrinter := cli.HelpPrinter
cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) {
if tmpl == AppHelpTemplate {
// Iterate over all the flags and add any uncategorized ones
categorized := make(map[string]struct{})
for _, group := range AppHelpFlagGroups {
for _, flag := range group.Flags {
categorized[flag.String()] = struct{}{}
}
}
uncategorized := []cli.Flag{}
for _, flag := range data.(*cli.App).Flags {
if _, ok := categorized[flag.String()]; !ok {
2018-05-23 22:32:26 -07:00
if strings.HasPrefix(flag.GetName(), "dashboard") {
continue
}
uncategorized = append(uncategorized, flag)
}
}
if len(uncategorized) > 0 {
// Append all ungategorized options to the misc group
miscs := len(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags)
AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = append(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags, uncategorized...)
// Make sure they are removed afterwards
defer func() {
AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags[:miscs]
}()
}
// Render out custom usage screen
originalHelpPrinter(w, tmpl, helpData{data, AppHelpFlagGroups})
} else if tmpl == utils.CommandHelpTemplate {
// Iterate over all command specific flags and categorize them
categorized := make(map[string][]cli.Flag)
for _, flag := range data.(cli.Command).Flags {
if _, ok := categorized[flag.String()]; !ok {
categorized[flagCategory(flag)] = append(categorized[flagCategory(flag)], flag)
}
}
// sort to get a stable ordering
sorted := make([]flagGroup, 0, len(categorized))
for cat, flgs := range categorized {
sorted = append(sorted, flagGroup{cat, flgs})
}
sort.Sort(byCategory(sorted))
// add sorted array to data and render with default printer
originalHelpPrinter(w, tmpl, map[string]interface{}{
"cmd": data,
"categorizedFlags": sorted,
})
} else {
originalHelpPrinter(w, tmpl, data)
}
}
}