2019-03-01 13:48:05 -06: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-20 22:57:25 -04:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
2019-07-23 08:58:20 -05:00
|
|
|
"github.com/prysmaticlabs/prysm/validator/flags"
|
2020-05-30 23:44:34 -07:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-03-01 13:48:05 -06: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 11:41:20 -04:00
|
|
|
cmd.MinimalConfigFlag,
|
|
|
|
cmd.E2EConfigFlag,
|
2019-03-01 13:48:05 -06:00
|
|
|
cmd.VerbosityFlag,
|
|
|
|
cmd.DataDirFlag,
|
2020-01-08 13:16:17 -05:00
|
|
|
cmd.ClearDB,
|
|
|
|
cmd.ForceClearDB,
|
2019-03-01 13:48:05 -06:00
|
|
|
cmd.EnableTracingFlag,
|
2019-05-11 17:43:55 -04:00
|
|
|
cmd.TracingProcessNameFlag,
|
2019-03-01 13:48:05 -06:00
|
|
|
cmd.TracingEndpointFlag,
|
|
|
|
cmd.TraceSampleFractionFlag,
|
2020-06-11 00:04:32 +08:00
|
|
|
cmd.MonitoringHostFlag,
|
2020-04-19 04:36:19 -04:00
|
|
|
flags.MonitoringPortFlag,
|
2020-10-01 02:55:56 +06:00
|
|
|
cmd.DisableMonitoringFlag,
|
2019-09-11 14:38:35 -04:00
|
|
|
cmd.LogFormat,
|
|
|
|
cmd.LogFileName,
|
2020-03-19 14:46:44 -07:00
|
|
|
cmd.ConfigFileFlag,
|
2020-05-05 17:19:27 -05:00
|
|
|
cmd.ChainConfigFileFlag,
|
2020-05-06 14:01:23 -07:00
|
|
|
cmd.GrpcMaxCallRecvMsgSizeFlag,
|
2019-03-01 13:48:05 -06:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
debug.PProfFlag,
|
|
|
|
debug.PProfAddrFlag,
|
|
|
|
debug.PProfPortFlag,
|
|
|
|
debug.MemProfileRateFlag,
|
|
|
|
debug.CPUProfileFlag,
|
|
|
|
debug.TraceFlag,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-07-23 08:58:20 -05:00
|
|
|
Name: "validator",
|
2019-03-01 13:48:05 -06:00
|
|
|
Flags: []cli.Flag{
|
2019-07-23 08:58:20 -05:00
|
|
|
flags.BeaconRPCProviderFlag,
|
2020-09-04 14:03:18 -05:00
|
|
|
flags.BeaconRPCGatewayProviderFlag,
|
2019-07-23 08:58:20 -05:00
|
|
|
flags.CertFlag,
|
2020-09-03 10:11:17 -05:00
|
|
|
flags.EnableWebFlag,
|
2020-10-09 07:58:30 -07:00
|
|
|
flags.WebHostFlag,
|
|
|
|
flags.WebPortFlag,
|
2020-01-24 17:21:31 +00:00
|
|
|
flags.KeyManager,
|
|
|
|
flags.KeyManagerOpts,
|
2019-07-23 08:58:20 -05:00
|
|
|
flags.KeystorePathFlag,
|
|
|
|
flags.PasswordFlag,
|
|
|
|
flags.DisablePenaltyRewardLogFlag,
|
2019-09-11 14:38:35 -04:00
|
|
|
flags.UnencryptedKeysFlag,
|
2019-12-07 12:13:56 -07:00
|
|
|
flags.GraffitiFlag,
|
2020-10-01 02:55:56 +06:00
|
|
|
flags.EnableRPCFlag,
|
2020-08-13 21:49:57 -05:00
|
|
|
flags.RPCHost,
|
|
|
|
flags.RPCPort,
|
|
|
|
flags.GRPCGatewayPort,
|
|
|
|
flags.GRPCGatewayHost,
|
2020-02-24 10:00:22 -08:00
|
|
|
flags.GrpcRetriesFlag,
|
2020-07-21 20:45:52 -07:00
|
|
|
flags.GrpcRetryDelayFlag,
|
2020-09-04 14:03:18 -05:00
|
|
|
flags.GPRCGatewayCorsDomain,
|
2020-03-25 09:29:04 -07:00
|
|
|
flags.GrpcHeadersFlag,
|
2020-05-20 18:23:22 +03:00
|
|
|
flags.SlasherRPCProviderFlag,
|
|
|
|
flags.SlasherCertFlag,
|
2020-06-04 04:23:17 +02:00
|
|
|
flags.SourceDirectories,
|
|
|
|
flags.SourceDirectory,
|
|
|
|
flags.TargetDirectory,
|
2020-05-19 06:44:54 -07:00
|
|
|
flags.DisableAccountMetricsFlag,
|
2020-07-08 00:01:09 -05:00
|
|
|
flags.WalletDirFlag,
|
2020-08-06 20:02:30 -04:00
|
|
|
flags.DeprecatedPasswordsDirFlag,
|
2020-07-28 20:20:13 -05:00
|
|
|
flags.WalletPasswordFileFlag,
|
2019-03-01 13:48:05 -06:00
|
|
|
},
|
|
|
|
},
|
2019-03-20 22:57:25 -04:00
|
|
|
{
|
|
|
|
Name: "features",
|
2020-03-19 14:46:44 -07:00
|
|
|
Flags: featureconfig.ActiveFlags(featureconfig.ValidatorFlags),
|
2019-03-20 22:57:25 -04:00
|
|
|
},
|
2019-09-11 14:38:35 -04:00
|
|
|
{
|
|
|
|
Name: "interop",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
flags.InteropNumValidators,
|
|
|
|
flags.InteropStartIndex,
|
|
|
|
},
|
|
|
|
},
|
2019-03-01 13:48:05 -06: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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|