cmd: group network and db path flags together (#24698)

This PR groups all built-in network flags together and list them in the command as a whole.

And all database path flags(datadir, ancient) are also grouped, since usually these two are
used together.
This commit is contained in:
rjl493456442
2022-05-03 08:46:17 +02:00
committed by GitHub
parent 5157d4540a
commit 344d6f95cf
9 changed files with 113 additions and 219 deletions
+36 -6
View File
@@ -144,17 +144,17 @@ var (
Name: "mainnet",
Usage: "Ethereum mainnet",
}
GoerliFlag = cli.BoolFlag{
Name: "goerli",
Usage: "Görli network: pre-configured proof-of-authority test network",
RopstenFlag = cli.BoolFlag{
Name: "ropsten",
Usage: "Ropsten network: pre-configured proof-of-work test network",
}
RinkebyFlag = cli.BoolFlag{
Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network",
}
RopstenFlag = cli.BoolFlag{
Name: "ropsten",
Usage: "Ropsten network: pre-configured proof-of-work test network",
GoerliFlag = cli.BoolFlag{
Name: "goerli",
Usage: "Görli network: pre-configured proof-of-authority test network",
}
SepoliaFlag = cli.BoolFlag{
Name: "sepolia",
@@ -823,6 +823,36 @@ var (
}
)
var (
// TestnetFlags is the flag group of all built-in supported testnets.
TestnetFlags = []cli.Flag{
RopstenFlag,
RinkebyFlag,
GoerliFlag,
SepoliaFlag,
KilnFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{
MainnetFlag,
}, TestnetFlags...)
// DatabasePathFlags is the flag group of all database path flags.
DatabasePathFlags = []cli.Flag{
DataDirFlag,
AncientFlag,
}
)
// GroupFlags combines the given flag slices together and returns the merged one.
func GroupFlags(groups ...[]cli.Flag) []cli.Flag {
var ret []cli.Flag
for _, group := range groups {
ret = append(ret, group...)
}
return ret
}
// MakeDataDir retrieves the currently requested data directory, terminating
// if none (or the empty string) is specified. If the node is starting a testnet,
// then a subdirectory of the specified datadir will be used.