mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
82 lines
1.8 KiB
Go
82 lines
1.8 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/v4/cmd"
|
|
"github.com/prysmaticlabs/prysm/v4/cmd/client-stats/flags"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
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.VerbosityFlag,
|
|
cmd.LogFormat,
|
|
cmd.LogFileName,
|
|
cmd.ConfigFileFlag,
|
|
},
|
|
},
|
|
{
|
|
Name: "client-stats",
|
|
Flags: []cli.Flag{
|
|
flags.BeaconnodeMetricsURLFlag,
|
|
flags.ValidatorMetricsURLFlag,
|
|
flags.ClientStatsAPIURLFlag,
|
|
flags.ScrapeIntervalFlag,
|
|
},
|
|
},
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|