2019-03-01 19:48:05 +00:00
|
|
|
// This code was adapted from https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/usage.go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/debug"
|
2019-03-21 02:57:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
2019-07-23 13:58:20 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/validator/flags"
|
2020-05-31 06:44:34 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-03-01 19:48:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var appHelpTemplate = `NAME:
|
|
|
|
{{.App.Name}} - {{.App.Usage}}
|
|
|
|
USAGE:
|
|
|
|
{{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}}
|
|
|
|
{{if .App.Version}}
|
|
|
|
AUTHOR:
|
|
|
|
{{range .App.Authors}}{{ . }}{{end}}
|
|
|
|
{{end}}{{if .App.Commands}}
|
|
|
|
GLOBAL OPTIONS:
|
|
|
|
{{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}}
|
|
|
|
VERSION:
|
|
|
|
{{.App.Version}}
|
|
|
|
{{end}}{{if len .App.Authors}}
|
|
|
|
{{end}}
|
|
|
|
`
|
|
|
|
|
|
|
|
type flagGroup struct {
|
|
|
|
Name string
|
|
|
|
Flags []cli.Flag
|
|
|
|
}
|
|
|
|
|
|
|
|
var appHelpFlagGroups = []flagGroup{
|
|
|
|
{
|
|
|
|
Name: "cmd",
|
|
|
|
Flags: []cli.Flag{
|
2020-06-23 15:41:20 +00:00
|
|
|
cmd.MinimalConfigFlag,
|
|
|
|
cmd.E2EConfigFlag,
|
2019-03-01 19:48:05 +00:00
|
|
|
cmd.VerbosityFlag,
|
|
|
|
cmd.DataDirFlag,
|
2020-01-08 18:16:17 +00:00
|
|
|
cmd.ClearDB,
|
|
|
|
cmd.ForceClearDB,
|
2019-03-01 19:48:05 +00:00
|
|
|
cmd.EnableTracingFlag,
|
2019-05-11 21:43:55 +00:00
|
|
|
cmd.TracingProcessNameFlag,
|
2019-03-01 19:48:05 +00:00
|
|
|
cmd.TracingEndpointFlag,
|
|
|
|
cmd.TraceSampleFractionFlag,
|
2020-06-10 16:04:32 +00:00
|
|
|
cmd.MonitoringHostFlag,
|
2020-04-19 08:36:19 +00:00
|
|
|
flags.MonitoringPortFlag,
|
2019-09-11 18:38:35 +00:00
|
|
|
cmd.LogFormat,
|
|
|
|
cmd.LogFileName,
|
2020-03-19 21:46:44 +00:00
|
|
|
cmd.ConfigFileFlag,
|
2020-05-05 22:19:27 +00:00
|
|
|
cmd.ChainConfigFileFlag,
|
2020-05-06 21:01:23 +00:00
|
|
|
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
2019-03-01 19:48:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
debug.PProfFlag,
|
|
|
|
debug.PProfAddrFlag,
|
|
|
|
debug.PProfPortFlag,
|
|
|
|
debug.MemProfileRateFlag,
|
|
|
|
debug.CPUProfileFlag,
|
|
|
|
debug.TraceFlag,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-07-23 13:58:20 +00:00
|
|
|
Name: "validator",
|
2019-03-01 19:48:05 +00:00
|
|
|
Flags: []cli.Flag{
|
2019-07-23 13:58:20 +00:00
|
|
|
flags.BeaconRPCProviderFlag,
|
|
|
|
flags.CertFlag,
|
2020-01-24 17:21:31 +00:00
|
|
|
flags.KeyManager,
|
|
|
|
flags.KeyManagerOpts,
|
2019-07-23 13:58:20 +00:00
|
|
|
flags.KeystorePathFlag,
|
|
|
|
flags.PasswordFlag,
|
|
|
|
flags.DisablePenaltyRewardLogFlag,
|
2019-09-11 18:38:35 +00:00
|
|
|
flags.UnencryptedKeysFlag,
|
2019-12-07 19:13:56 +00:00
|
|
|
flags.GraffitiFlag,
|
2020-08-14 02:49:57 +00:00
|
|
|
flags.RPCHost,
|
|
|
|
flags.RPCPort,
|
|
|
|
flags.GRPCGatewayPort,
|
|
|
|
flags.GRPCGatewayHost,
|
2020-02-24 18:00:22 +00:00
|
|
|
flags.GrpcRetriesFlag,
|
2020-07-22 03:45:52 +00:00
|
|
|
flags.GrpcRetryDelayFlag,
|
2020-03-25 16:29:04 +00:00
|
|
|
flags.GrpcHeadersFlag,
|
2020-05-20 15:23:22 +00:00
|
|
|
flags.SlasherRPCProviderFlag,
|
|
|
|
flags.SlasherCertFlag,
|
2020-06-04 02:23:17 +00:00
|
|
|
flags.SourceDirectories,
|
|
|
|
flags.SourceDirectory,
|
|
|
|
flags.TargetDirectory,
|
2020-05-19 13:44:54 +00:00
|
|
|
flags.DisableAccountMetricsFlag,
|
2020-07-08 05:01:09 +00:00
|
|
|
flags.WalletDirFlag,
|
2020-08-07 00:02:30 +00:00
|
|
|
flags.DeprecatedPasswordsDirFlag,
|
2020-07-29 01:20:13 +00:00
|
|
|
flags.WalletPasswordFileFlag,
|
2019-03-01 19:48:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 02:57:25 +00:00
|
|
|
{
|
|
|
|
Name: "features",
|
2020-03-19 21:46:44 +00:00
|
|
|
Flags: featureconfig.ActiveFlags(featureconfig.ValidatorFlags),
|
2019-03-21 02:57:25 +00:00
|
|
|
},
|
2019-09-11 18:38:35 +00:00
|
|
|
{
|
|
|
|
Name: "interop",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
flags.InteropNumValidators,
|
|
|
|
flags.InteropStartIndex,
|
|
|
|
},
|
|
|
|
},
|
2019-03-01 19:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cli.AppHelpTemplate = appHelpTemplate
|
|
|
|
|
|
|
|
type helpData struct {
|
|
|
|
App interface{}
|
|
|
|
FlagGroups []flagGroup
|
|
|
|
}
|
|
|
|
|
|
|
|
originalHelpPrinter := cli.HelpPrinter
|
|
|
|
cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) {
|
|
|
|
if tmpl == appHelpTemplate {
|
|
|
|
for _, group := range appHelpFlagGroups {
|
|
|
|
sort.Sort(cli.FlagsByName(group.Flags))
|
|
|
|
}
|
|
|
|
originalHelpPrinter(w, tmpl, helpData{data, appHelpFlagGroups})
|
|
|
|
} else {
|
|
|
|
originalHelpPrinter(w, tmpl, data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|