cmd/geth, cmd/devp2p: fix some cli parsing issues (#25234)

* cmd/geth: add some missing argument count checks

* internal/flags: skip cmds with no action func in MigrateGlobalFlags

* internal/flags: add Merge

* cmd/devp2p: re-add listener config flags in discv4 commands
This commit is contained in:
Felix Lange
2022-07-04 19:52:19 +02:00
committed by GitHub
parent 55f914a1d7
commit f6ac80c507
4 changed files with 34 additions and 5 deletions
+13
View File
@@ -38,6 +38,15 @@ func NewApp(gitCommit, gitDate, usage string) *cli.App {
return app
}
// Merge merges the given flag slices.
func Merge(groups ...[]cli.Flag) []cli.Flag {
var ret []cli.Flag
for _, group := range groups {
ret = append(ret, group...)
}
return ret
}
var migrationApplied = map[*cli.Command]struct{}{}
// MigrateGlobalFlags makes all global flag values available in the
@@ -70,6 +79,10 @@ func MigrateGlobalFlags(ctx *cli.Context) {
// This iterates over all commands and wraps their action function.
iterate(ctx.App.Commands, func(cmd *cli.Command) {
if cmd.Action == nil {
return
}
action := cmd.Action
cmd.Action = func(ctx *cli.Context) error {
doMigrateFlags(ctx)