github.com/aswedchain/aswed@v1.0.1/cmd/geth/usage.go (about) 1 // Copyright 2015 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 // Contains the geth command usage template and generator. 18 19 package main 20 21 import ( 22 "io" 23 "sort" 24 25 "github.com/aswedchain/aswed/cmd/utils" 26 "github.com/aswedchain/aswed/internal/debug" 27 "github.com/aswedchain/aswed/internal/flags" 28 cli "gopkg.in/urfave/cli.v1" 29 ) 30 31 // AppHelpFlagGroups is the application flags, grouped by functionality. 32 var AppHelpFlagGroups = []flags.FlagGroup{ 33 { 34 Name: "ETHEREUM", 35 Flags: []cli.Flag{ 36 configFileFlag, 37 utils.DataDirFlag, 38 utils.AncientFlag, 39 utils.KeyStoreDirFlag, 40 utils.NoUSBFlag, 41 utils.SmartCardDaemonPathFlag, 42 utils.NetworkIdFlag, 43 utils.TestnetFlag, 44 utils.SyncModeFlag, 45 utils.ExitWhenSyncedFlag, 46 utils.GCModeFlag, 47 utils.TxLookupLimitFlag, 48 utils.EthStatsURLFlag, 49 utils.IdentityFlag, 50 utils.LightKDFFlag, 51 utils.WhitelistFlag, 52 }, 53 }, 54 { 55 Name: "LIGHT CLIENT", 56 Flags: []cli.Flag{ 57 utils.LightServeFlag, 58 utils.LightIngressFlag, 59 utils.LightEgressFlag, 60 utils.LightMaxPeersFlag, 61 utils.UltraLightServersFlag, 62 utils.UltraLightFractionFlag, 63 utils.UltraLightOnlyAnnounceFlag, 64 utils.LightNoPruneFlag, 65 }, 66 }, 67 { 68 Name: "DEVELOPER CHAIN", 69 Flags: []cli.Flag{ 70 utils.DeveloperFlag, 71 utils.DeveloperPeriodFlag, 72 }, 73 }, 74 { 75 Name: "ETHASH", 76 Flags: []cli.Flag{ 77 utils.EthashCacheDirFlag, 78 utils.EthashCachesInMemoryFlag, 79 utils.EthashCachesOnDiskFlag, 80 utils.EthashCachesLockMmapFlag, 81 utils.EthashDatasetDirFlag, 82 utils.EthashDatasetsInMemoryFlag, 83 utils.EthashDatasetsOnDiskFlag, 84 utils.EthashDatasetsLockMmapFlag, 85 }, 86 }, 87 { 88 Name: "TRANSACTION POOL", 89 Flags: []cli.Flag{ 90 utils.TxPoolLocalsFlag, 91 utils.TxPoolNoLocalsFlag, 92 utils.TxPoolJournalFlag, 93 utils.TxPoolRejournalFlag, 94 utils.TxPoolPriceLimitFlag, 95 utils.TxPoolPriceBumpFlag, 96 utils.TxPoolAccountSlotsFlag, 97 utils.TxPoolGlobalSlotsFlag, 98 utils.TxPoolAccountQueueFlag, 99 utils.TxPoolGlobalQueueFlag, 100 utils.TxPoolLifetimeFlag, 101 }, 102 }, 103 { 104 Name: "PERFORMANCE TUNING", 105 Flags: []cli.Flag{ 106 utils.CacheFlag, 107 utils.CacheDatabaseFlag, 108 utils.CacheTrieFlag, 109 utils.CacheTrieJournalFlag, 110 utils.CacheTrieRejournalFlag, 111 utils.CacheGCFlag, 112 utils.CacheSnapshotFlag, 113 utils.CacheNoPrefetchFlag, 114 }, 115 }, 116 { 117 Name: "ACCOUNT", 118 Flags: []cli.Flag{ 119 utils.UnlockedAccountFlag, 120 utils.PasswordFileFlag, 121 utils.ExternalSignerFlag, 122 utils.InsecureUnlockAllowedFlag, 123 }, 124 }, 125 { 126 Name: "API AND CONSOLE", 127 Flags: []cli.Flag{ 128 utils.IPCDisabledFlag, 129 utils.IPCPathFlag, 130 utils.HTTPEnabledFlag, 131 utils.HTTPListenAddrFlag, 132 utils.HTTPPortFlag, 133 utils.HTTPApiFlag, 134 utils.HTTPCORSDomainFlag, 135 utils.HTTPVirtualHostsFlag, 136 utils.WSEnabledFlag, 137 utils.WSListenAddrFlag, 138 utils.WSPortFlag, 139 utils.WSApiFlag, 140 utils.WSAllowedOriginsFlag, 141 utils.GraphQLEnabledFlag, 142 utils.GraphQLCORSDomainFlag, 143 utils.GraphQLVirtualHostsFlag, 144 utils.RPCGlobalGasCapFlag, 145 utils.RPCGlobalTxFeeCapFlag, 146 utils.JSpathFlag, 147 utils.ExecFlag, 148 utils.PreloadJSFlag, 149 }, 150 }, 151 { 152 Name: "NETWORKING", 153 Flags: []cli.Flag{ 154 utils.BootnodesFlag, 155 utils.LegacyBootnodesV4Flag, 156 utils.LegacyBootnodesV5Flag, 157 utils.DNSDiscoveryFlag, 158 utils.ListenPortFlag, 159 utils.MaxPeersFlag, 160 utils.MaxPendingPeersFlag, 161 utils.NATFlag, 162 utils.NoDiscoverFlag, 163 utils.DiscoveryV5Flag, 164 utils.NetrestrictFlag, 165 utils.NodeKeyFileFlag, 166 utils.NodeKeyHexFlag, 167 }, 168 }, 169 { 170 Name: "MINER", 171 Flags: []cli.Flag{ 172 utils.MiningEnabledFlag, 173 utils.MinerThreadsFlag, 174 utils.MinerNotifyFlag, 175 utils.MinerGasPriceFlag, 176 utils.MinerGasTargetFlag, 177 utils.MinerGasLimitFlag, 178 utils.MinerEtherbaseFlag, 179 utils.MinerExtraDataFlag, 180 utils.MinerRecommitIntervalFlag, 181 utils.MinerNoVerfiyFlag, 182 }, 183 }, 184 { 185 Name: "GAS PRICE ORACLE", 186 Flags: []cli.Flag{ 187 utils.GpoBlocksFlag, 188 utils.GpoPercentileFlag, 189 utils.GpoMaxGasPriceFlag, 190 }, 191 }, 192 { 193 Name: "VIRTUAL MACHINE", 194 Flags: []cli.Flag{ 195 utils.VMEnableDebugFlag, 196 utils.EVMInterpreterFlag, 197 utils.EWASMInterpreterFlag, 198 }, 199 }, 200 { 201 Name: "LOGGING AND DEBUGGING", 202 Flags: append([]cli.Flag{ 203 utils.FakePoWFlag, 204 utils.NoCompactionFlag, 205 }, debug.Flags...), 206 }, 207 { 208 Name: "METRICS AND STATS", 209 Flags: metricsFlags, 210 }, 211 { 212 Name: "WHISPER (deprecated)", 213 Flags: whisperFlags, 214 }, 215 { 216 Name: "ALIASED (deprecated)", 217 Flags: append([]cli.Flag{ 218 utils.LegacyRPCEnabledFlag, 219 utils.LegacyRPCListenAddrFlag, 220 utils.LegacyRPCPortFlag, 221 utils.LegacyRPCCORSDomainFlag, 222 utils.LegacyRPCVirtualHostsFlag, 223 utils.LegacyRPCApiFlag, 224 utils.LegacyWSListenAddrFlag, 225 utils.LegacyWSPortFlag, 226 utils.LegacyWSAllowedOriginsFlag, 227 utils.LegacyWSApiFlag, 228 utils.LegacyGpoBlocksFlag, 229 utils.LegacyGpoPercentileFlag, 230 utils.LegacyGraphQLListenAddrFlag, 231 utils.LegacyGraphQLPortFlag, 232 }, debug.DeprecatedFlags...), 233 }, 234 { 235 Name: "MISC", 236 Flags: []cli.Flag{ 237 utils.SnapshotFlag, 238 cli.HelpFlag, 239 }, 240 }, 241 } 242 243 func init() { 244 // Override the default app help template 245 cli.AppHelpTemplate = flags.AppHelpTemplate 246 247 // Override the default app help printer, but only for the global app help 248 originalHelpPrinter := cli.HelpPrinter 249 cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) { 250 if tmpl == flags.AppHelpTemplate { 251 // Iterate over all the flags and add any uncategorized ones 252 categorized := make(map[string]struct{}) 253 for _, group := range AppHelpFlagGroups { 254 for _, flag := range group.Flags { 255 categorized[flag.String()] = struct{}{} 256 } 257 } 258 deprecated := make(map[string]struct{}) 259 for _, flag := range utils.DeprecatedFlags { 260 deprecated[flag.String()] = struct{}{} 261 } 262 // Only add uncategorized flags if they are not deprecated 263 var uncategorized []cli.Flag 264 for _, flag := range data.(*cli.App).Flags { 265 if _, ok := categorized[flag.String()]; !ok { 266 if _, ok := deprecated[flag.String()]; !ok { 267 uncategorized = append(uncategorized, flag) 268 } 269 } 270 } 271 if len(uncategorized) > 0 { 272 // Append all ungategorized options to the misc group 273 miscs := len(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags) 274 AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = append(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags, uncategorized...) 275 276 // Make sure they are removed afterwards 277 defer func() { 278 AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags[:miscs] 279 }() 280 } 281 // Render out custom usage screen 282 originalHelpPrinter(w, tmpl, flags.HelpData{App: data, FlagGroups: AppHelpFlagGroups}) 283 } else if tmpl == flags.CommandHelpTemplate { 284 // Iterate over all command specific flags and categorize them 285 categorized := make(map[string][]cli.Flag) 286 for _, flag := range data.(cli.Command).Flags { 287 if _, ok := categorized[flag.String()]; !ok { 288 categorized[flags.FlagCategory(flag, AppHelpFlagGroups)] = append(categorized[flags.FlagCategory(flag, AppHelpFlagGroups)], flag) 289 } 290 } 291 292 // sort to get a stable ordering 293 sorted := make([]flags.FlagGroup, 0, len(categorized)) 294 for cat, flgs := range categorized { 295 sorted = append(sorted, flags.FlagGroup{Name: cat, Flags: flgs}) 296 } 297 sort.Sort(flags.ByCategory(sorted)) 298 299 // add sorted array to data and render with default printer 300 originalHelpPrinter(w, tmpl, map[string]interface{}{ 301 "cmd": data, 302 "categorizedFlags": sorted, 303 }) 304 } else { 305 originalHelpPrinter(w, tmpl, data) 306 } 307 } 308 }