mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
9ac950f480
* Added the 'enable-upnp' flag to the list of supported command line arguments. If the user specifies this feature flag (adds --enable-upnp as an argument) - the Beacon-chain and Validator services, when started, will initialize libp2p with the UPNP options. * Added the new arg to usage.go due to test failure * Update shared/p2p/service.go Changed the logging according to Preston's recommendation. Co-Authored-By: Preston Van Loon <preston@prysmaticlabs.com> * Code review changes: 1. File formatting. 2. Command line arg more detailed description.
132 lines
2.7 KiB
Go
132 lines
2.7 KiB
Go
// 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/beacon-chain/utils"
|
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
|
"github.com/prysmaticlabs/prysm/shared/debug"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
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{
|
|
cmd.NoDiscovery,
|
|
cmd.BootstrapNode,
|
|
cmd.RelayNode,
|
|
cmd.P2PPort,
|
|
cmd.DataDirFlag,
|
|
cmd.VerbosityFlag,
|
|
cmd.EnableTracingFlag,
|
|
cmd.TracingProcessNameFlag,
|
|
cmd.TracingEndpointFlag,
|
|
cmd.TraceSampleFractionFlag,
|
|
cmd.MonitoringPortFlag,
|
|
cmd.DisableMonitoringFlag,
|
|
cmd.MaxGoroutines,
|
|
cmd.ClearDB,
|
|
},
|
|
},
|
|
{
|
|
Name: "debug",
|
|
Flags: []cli.Flag{
|
|
debug.PProfFlag,
|
|
debug.PProfAddrFlag,
|
|
debug.PProfPortFlag,
|
|
debug.MemProfileRateFlag,
|
|
debug.CPUProfileFlag,
|
|
debug.TraceFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "utils",
|
|
Flags: []cli.Flag{
|
|
utils.NoCustomConfigFlag,
|
|
utils.DepositContractFlag,
|
|
utils.Web3ProviderFlag,
|
|
utils.RPCPort,
|
|
utils.CertFlag,
|
|
utils.KeyFlag,
|
|
utils.EnableDBCleanup,
|
|
utils.GRPCGatewayPort,
|
|
utils.HTTPWeb3ProviderFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "p2p",
|
|
Flags: []cli.Flag{
|
|
cmd.P2PHost,
|
|
cmd.P2PMaxPeers,
|
|
cmd.P2PPrivKey,
|
|
cmd.P2PWhitelist,
|
|
cmd.StaticPeers,
|
|
cmd.EnableUPnPFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "log",
|
|
Flags: []cli.Flag{
|
|
cmd.LogFormat,
|
|
cmd.LogFileName,
|
|
},
|
|
},
|
|
{
|
|
Name: "features",
|
|
Flags: featureconfig.BeaconChainFlags,
|
|
},
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|