mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
uncategorized flags, if not deprecated, displayed under misc
This commit is contained in:
parent
7bc1257823
commit
428afc5e1a
2 changed files with 32 additions and 2 deletions
|
|
@ -315,6 +315,36 @@ 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{}{}
|
||||
}
|
||||
}
|
||||
deprecated := make(map[string]struct{})
|
||||
for _, flag := range utils.DeprecatedFlags {
|
||||
deprecated[flag.String()] = struct{}{}
|
||||
}
|
||||
// Only add uncategorized flags if they are not deprecated
|
||||
var uncategorized []cli.Flag
|
||||
for _, flag := range data.(*cli.App).Flags {
|
||||
if _, ok := categorized[flag.String()]; !ok {
|
||||
if _, ok := deprecated[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 {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ var ShowDeprecated = cli.Command{
|
|||
Description: "Show flags that have been deprecated and will soon be removed",
|
||||
}
|
||||
|
||||
var deprecatedFlags = []cli.Flag{
|
||||
var DeprecatedFlags = []cli.Flag{
|
||||
LegacyTestnetFlag,
|
||||
LegacyLightServFlag,
|
||||
LegacyLightPeersFlag,
|
||||
|
|
@ -157,7 +157,7 @@ func showDeprecated(*cli.Context) {
|
|||
fmt.Println("--------------------------------------------------------------------")
|
||||
fmt.Println()
|
||||
|
||||
for _, flag := range deprecatedFlags {
|
||||
for _, flag := range DeprecatedFlags {
|
||||
fmt.Println(flag.String())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue