From 2ad9cbc11ef130727eba08dfdf0125cfbf997657 Mon Sep 17 00:00:00 2001 From: renaynay <41963722+renaynay@users.noreply.github.com> Date: Fri, 24 Apr 2020 15:53:39 +0200 Subject: [PATCH] show-deprecated-flags command cleaned up --- cmd/geth/main.go | 2 +- cmd/geth/usage.go | 27 ++++----------------------- cmd/utils/flags_legacy.go | 27 +++++++++++++++------------ 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 78c4af8881..8b6acc79e4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -239,6 +239,7 @@ func init() { dumpConfigCommand, // See retesteth.go retestethCommand, + // See cmd/utils/flags_legacy.go utils.ShowDeprecated, } sort.Sort(cli.CommandsByName(app.Commands)) @@ -462,7 +463,6 @@ func startNode(ctx *cli.Context, stack *node.Node) { gasprice := utils.GlobalBig(ctx, utils.MinerGasPriceFlag.Name) if ctx.IsSet(utils.LegacyMinerGasPriceFlag.Name) && !ctx.IsSet(utils.MinerGasPriceFlag.Name) { gasprice = utils.GlobalBig(ctx, utils.LegacyMinerGasPriceFlag.Name) - log.Warn("The flag --gasprice is deprecated and will be removed in the future, please use --miner.gasprice") } ethereum.TxPool().SetGasPrice(gasprice) diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 5b8a45f4c2..d1d61a6b0a 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -261,6 +261,10 @@ var AppHelpFlagGroups = []flagGroup{ }, { Name: "MISC", + Flags: []cli.Flag{ + utils.SnapshotFlag, + cli.HelpFlag, + }, }, } @@ -311,29 +315,6 @@ func init() { originalHelpPrinter := cli.HelpPrinter cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) { if tmpl == AppHelpTemplate { - // Iterate over all the flags and add any uncategorized ones - categorized := make(map[string]struct{}) - for _, group := range AppHelpFlagGroups { - for _, flag := range group.Flags { - categorized[flag.String()] = struct{}{} - } - } - var uncategorized []cli.Flag - for _, flag := range data.(*cli.App).Flags { - if _, ok := categorized[flag.String()]; !ok { - uncategorized = append(uncategorized, flag) - } - } - if len(uncategorized) > 0 { - // Append all ungategorized options to the misc group - miscs := len(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags) - AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = append(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags, uncategorized...) - - // Make sure they are removed afterwards - defer func() { - AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags[:miscs] - }() - } // Render out custom usage screen originalHelpPrinter(w, tmpl, helpData{data, AppHelpFlagGroups}) } else if tmpl == utils.CommandHelpTemplate { diff --git a/cmd/utils/flags_legacy.go b/cmd/utils/flags_legacy.go index 3e37537103..3b7e14da86 100644 --- a/cmd/utils/flags_legacy.go +++ b/cmd/utils/flags_legacy.go @@ -29,19 +29,22 @@ var ShowDeprecated = cli.Command{ Action: showDeprecated, Name: "show-deprecated-flags", Usage: "Show flags that have been deprecated", - Flags: []cli.Flag{ - LegacyTestnetFlag, - LegacyLightServFlag, - LegacyLightPeersFlag, - LegacyMinerThreadsFlag, - LegacyMinerGasTargetFlag, - LegacyMinerGasPriceFlag, - LegacyMinerEtherbaseFlag, - LegacyMinerExtraDataFlag, - }, + ArgsUsage: " ", + Category: "MISCELLANEOUS COMMANDS", Description: "Show flags that have been deprecated and will soon be removed", } +var deprecatedFlags = []cli.Flag{ + LegacyTestnetFlag, + LegacyLightServFlag, + LegacyLightPeersFlag, + LegacyMinerThreadsFlag, + LegacyMinerGasTargetFlag, + LegacyMinerGasPriceFlag, + LegacyMinerEtherbaseFlag, + LegacyMinerExtraDataFlag, +} + var ( // (Deprecated April 2018) LegacyMinerThreadsFlag = cli.IntFlag{ @@ -148,13 +151,13 @@ var ( ) // showDeprecated displays deprecated flags that will be soon removed from the codebase. -func showDeprecated(c *cli.Context) { +func showDeprecated(*cli.Context) { fmt.Println("--------------------------------------------------------------------") fmt.Println("The following flags are deprecated and will be removed in the future!") fmt.Println("--------------------------------------------------------------------") fmt.Println() - for _, flag := range c.Command.Flags { + for _, flag := range deprecatedFlags { fmt.Println(flag.String()) } }