2019-10-31 03:26:55 +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"
|
2020-05-06 22:17:36 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
2019-10-31 03:26:55 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/slasher/flags"
|
2020-05-31 06:44:34 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2019-10-31 03:26:55 +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-10-31 03:26:55 +00:00
|
|
|
cmd.VerbosityFlag,
|
|
|
|
cmd.DataDirFlag,
|
|
|
|
cmd.EnableTracingFlag,
|
|
|
|
cmd.TracingProcessNameFlag,
|
|
|
|
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-10-31 03:26:55 +00:00
|
|
|
cmd.LogFormat,
|
|
|
|
cmd.LogFileName,
|
2020-02-14 07:09:54 +00:00
|
|
|
cmd.ForceClearDB,
|
2020-01-29 01:44:51 +00:00
|
|
|
cmd.ClearDB,
|
2020-04-27 14:14:26 +00:00
|
|
|
cmd.ConfigFileFlag,
|
2019-10-31 03:26:55 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug",
|
|
|
|
Flags: []cli.Flag{
|
|
|
|
debug.PProfFlag,
|
|
|
|
debug.PProfAddrFlag,
|
|
|
|
debug.PProfPortFlag,
|
|
|
|
debug.MemProfileRateFlag,
|
|
|
|
debug.CPUProfileFlag,
|
|
|
|
debug.TraceFlag,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "slasher",
|
|
|
|
Flags: []cli.Flag{
|
2020-02-14 07:09:54 +00:00
|
|
|
flags.BeaconCertFlag,
|
2020-05-26 02:08:15 +00:00
|
|
|
flags.CertFlag,
|
2019-10-31 03:26:55 +00:00
|
|
|
flags.KeyFlag,
|
|
|
|
flags.RPCPort,
|
2020-05-20 15:23:22 +00:00
|
|
|
flags.RPCHost,
|
2020-01-22 05:39:21 +00:00
|
|
|
flags.RebuildSpanMapsFlag,
|
|
|
|
flags.BeaconRPCProviderFlag,
|
2019-10-31 03:26:55 +00:00
|
|
|
},
|
|
|
|
},
|
2020-05-06 22:17:36 +00:00
|
|
|
{
|
|
|
|
Name: "features",
|
|
|
|
Flags: featureconfig.ActiveFlags(featureconfig.SlasherFlags),
|
|
|
|
},
|
2019-10-31 03:26:55 +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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|