Skip to content

Commit

Permalink
cmd/geth: different way to construct flags
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Apr 29, 2022
1 parent e25b41f commit fe769c9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
48 changes: 24 additions & 24 deletions cmd/geth/dbcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,29 @@ Remove blockchain and state databases`,
Action: utils.MigrateFlags(inspect),
Name: "inspect",
ArgsUsage: "<prefix> <start>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Usage: "Inspect the storage size for each type of data in the database",
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
}
dbStatCmd = cli.Command{
Action: utils.MigrateFlags(dbStats),
Name: "stats",
Usage: "Print leveldb statistics",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
}
dbCompactCmd = cli.Command{
Action: utils.MigrateFlags(dbCompact),
Name: "compact",
Usage: "Compact leveldb database. WARNING: May take a very long time",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
utils.CacheFlag,
utils.CacheDatabaseFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: `This command performs a database compaction.
WARNING: This operation may take a very long time to finish, and may cause database
corruption if it is aborted during execution'!`,
Expand All @@ -110,19 +110,19 @@ corruption if it is aborted during execution'!`,
Name: "get",
Usage: "Show the value of a database key",
ArgsUsage: "<hex-encoded key>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: "This command looks up the specified database key from the database.",
}
dbDeleteCmd = cli.Command{
Action: utils.MigrateFlags(dbDelete),
Name: "delete",
Usage: "Delete a database key (WARNING: may corrupt your database)",
ArgsUsage: "<hex-encoded key>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: `This command deletes the specified database key from the database.
WARNING: This is a low-level operation which may cause database corruption!`,
}
Expand All @@ -131,9 +131,9 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name: "put",
Usage: "Set the value of a database key (WARNING: may corrupt your database)",
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: `This command sets a given database key to the given value.
WARNING: This is a low-level operation which may cause database corruption!`,
}
Expand All @@ -142,58 +142,58 @@ WARNING: This is a low-level operation which may cause database corruption!`,
Name: "dumptrie",
Usage: "Show the storage key/values of a given storage trie",
ArgsUsage: "<hex-encoded storage trie root> <hex-encoded start (optional)> <int max elements (optional)>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: "This command looks up the specified database key from the database.",
}
dbDumpFreezerIndex = cli.Command{
Action: utils.MigrateFlags(freezerInspect),
Name: "freezer-index",
Usage: "Dump out the index of a given freezer type",
ArgsUsage: "<type> <start (int)> <end (int)>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: "This command displays information about the freezer index.",
}
dbImportCmd = cli.Command{
Action: utils.MigrateFlags(importLDBdata),
Name: "import",
Usage: "Imports leveldb-data from an exported RLP dump.",
ArgsUsage: "<dumpfile> <start (optional)",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: "The import command imports the specific chain data from an RLP encoded stream.",
}
dbExportCmd = cli.Command{
Action: utils.MigrateFlags(exportChaindata),
Name: "export",
Usage: "Exports the chain data into an RLP dump. If the <dumpfile> has .gz suffix, gzip compression will be used.",
ArgsUsage: "<type> <dumpfile>",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: "Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed.",
}
dbMetadataCmd = cli.Command{
Action: utils.MigrateFlags(showMetaData),
Name: "metadata",
Usage: "Shows metadata about the chain status.",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: "Shows metadata about the chain status.",
}
dbMigrateFreezerCmd = cli.Command{
Action: utils.MigrateFlags(freezerMigrate),
Name: "freezer-migrate",
Usage: "Migrate legacy parts of the freezer. (WARNING: may take a long time)",
ArgsUsage: "",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.SyncModeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: `The freezer-migrate command checks your database for receipts in a legacy format and updates those.
WARNING: please back-up the receipt files in your ancients before running this command.`,
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var (
// The app that holds all commands and flags.
app = flags.NewApp(gitCommit, gitDate, "the go-ethereum command line interface")
// flags that configure the node
nodeFlags = append([]cli.Flag{
nodeFlags = utils.GroupFlags([]cli.Flag{
utils.IdentityFlag,
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
Expand Down Expand Up @@ -152,7 +152,7 @@ var (
utils.GpoIgnoreGasPriceFlag,
utils.MinerNotifyFullFlag,
configFileFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...)
}, utils.NetworkFlags, utils.DatabasePathFlags)

rpcFlags = []cli.Flag{
utils.HTTPEnabledFlag,
Expand Down
8 changes: 4 additions & 4 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ var (
ArgsUsage: "<root>",
Action: utils.MigrateFlags(pruneState),
Category: "MISCELLANEOUS COMMANDS",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.CacheTrieJournalFlag,
utils.BloomFilterSizeFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: `
geth snapshot prune-state <state-root>
will prune historical state data with the help of the state snapshot.
Expand Down Expand Up @@ -144,12 +144,12 @@ It's also usable without snapshot enabled.
ArgsUsage: "[? <blockHash> | <blockNum>]",
Action: utils.MigrateFlags(dumpState),
Category: "MISCELLANEOUS COMMANDS",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
utils.ExcludeCodeFlag,
utils.ExcludeStorageFlag,
utils.StartKeyFlag,
utils.DumpLimitFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
Description: `
This command is semantically equivalent to 'geth dump', but uses the snapshots
as the backend data source, making this command a lot faster.
Expand Down
4 changes: 2 additions & 2 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
var AppHelpFlagGroups = []flags.FlagGroup{
{
Name: "ETHEREUM",
Flags: append([]cli.Flag{
Flags: utils.GroupFlags([]cli.Flag{
configFileFlag,
utils.MinFreeDiskSpaceFlag,
utils.KeyStoreDirFlag,
Expand All @@ -47,7 +47,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.IdentityFlag,
utils.LightKDFFlag,
utils.EthPeerRequiredBlocksFlag,
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
}, utils.NetworkFlags, utils.DatabasePathFlags),
},
{
Name: "LIGHT CLIENT",
Expand Down

0 comments on commit fe769c9

Please sign in to comment.