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
+4 -2
View File
@@ -166,10 +166,12 @@ This command dumps out the state for a given block (or latest, if none provided)
// initGenesis will initialise the given JSON format genesis file and writes it as
// the zero'd block (i.e. genesis) or will fail hard if it can't succeed.
func initGenesis(ctx *cli.Context) error {
// Make sure we have a valid genesis JSON
if ctx.Args().Len() != 1 {
utils.Fatalf("need genesis.json file as the only argument")
}
genesisPath := ctx.Args().First()
if len(genesisPath) == 0 {
utils.Fatalf("Must supply path to genesis JSON file")
utils.Fatalf("invalid path to genesis file")
}
file, err := os.Open(genesisPath)
if err != nil {
+4
View File
@@ -114,6 +114,10 @@ func localConsole(ctx *cli.Context) error {
// remoteConsole will connect to a remote geth instance, attaching a JavaScript
// console to it.
func remoteConsole(ctx *cli.Context) error {
if ctx.Args().Len() > 1 {
utils.Fatalf("invalid command-line: too many arguments")
}
endpoint := ctx.Args().First()
if endpoint == "" {
cfg := defaultNodeConfig()