This commit is contained in:
nicozingarelli 2018-06-14 15:06:16 +00:00 committed by GitHub
commit b5b38c17f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 35 deletions

View file

@ -38,7 +38,7 @@ import (
) )
var ( var (
//flag definition for the dumpconfig command // DumpConfigCommand defines the flag for the dumpconfig command.
DumpConfigCommand = cli.Command{ DumpConfigCommand = cli.Command{
Action: utils.MigrateFlags(dumpConfig), Action: utils.MigrateFlags(dumpConfig),
Name: "dumpconfig", Name: "dumpconfig",
@ -49,7 +49,7 @@ var (
Description: `The dumpconfig command shows configuration values.`, Description: `The dumpconfig command shows configuration values.`,
} }
//flag definition for the config file command // SwarmTomlConfigPathFlag defines the flag for the config file command.
SwarmTomlConfigPathFlag = cli.StringFlag{ SwarmTomlConfigPathFlag = cli.StringFlag{
Name: "config", Name: "config",
Usage: "TOML configuration file", Usage: "TOML configuration file",

View file

@ -142,11 +142,12 @@ var (
EnvVar: SWARM_ENV_CORS, EnvVar: SWARM_ENV_CORS,
} }
// the following flags are deprecated and should be removed in the future // DeprecatedEthAPIFlag is deprecated and should be removed in the future.
DeprecatedEthAPIFlag = cli.StringFlag{ DeprecatedEthAPIFlag = cli.StringFlag{
Name: "ethapi", Name: "ethapi",
Usage: "DEPRECATED: please use --ens-api and --swap-api", Usage: "DEPRECATED: please use --ens-api and --swap-api",
} }
// DeprecatedEnsAddrFlag is deprecated and should be removed in the future.
DeprecatedEnsAddrFlag = cli.StringFlag{ DeprecatedEnsAddrFlag = cli.StringFlag{
Name: "ens-addr", Name: "ens-addr",
Usage: "DEPRECATED: ENS contract address, please use --ens-api with contract address according to its format", Usage: "DEPRECATED: ENS contract address, please use --ens-api with contract address according to its format",

View file

@ -31,23 +31,23 @@ import (
"gopkg.in/urfave/cli.v1" "gopkg.in/urfave/cli.v1"
) )
// Custom type which is registered in the flags library which cli uses for // DirectoryString is a custom type that is registered in the flags library which cli
// argument parsing. This allows us to expand Value to an absolute path when // uses for argument parsing. This allows us to expand Value to an absolute path when
// the argument is parsed // the argument is parsed.
type DirectoryString struct { type DirectoryString struct {
Value string Value string
} }
func (self *DirectoryString) String() string { func (ds *DirectoryString) String() string {
return self.Value return ds.Value
} }
func (self *DirectoryString) Set(value string) error { func (ds *DirectoryString) Set(value string) error {
self.Value = expandPath(value) ds.Value = expandPath(value)
return nil return nil
} }
// Custom cli.Flag type which expand the received string to an absolute path. // DirectoryFlag is a custom cli.Flag type that expands the received string to an absolute path.
// e.g. ~/.ethereum -> /home/username/.ethereum // e.g. ~/.ethereum -> /home/username/.ethereum
type DirectoryFlag struct { type DirectoryFlag struct {
Name string Name string
@ -55,12 +55,12 @@ type DirectoryFlag struct {
Usage string Usage string
} }
func (self DirectoryFlag) String() string { func (df DirectoryFlag) String() string {
fmtString := "%s %v\t%v" fmtString := "%s %v\t%v"
if len(self.Value.Value) > 0 { if len(df.Value.Value) > 0 {
fmtString = "%s \"%v\"\t%v" fmtString = "%s \"%v\"\t%v"
} }
return fmt.Sprintf(fmtString, prefixedNames(self.Name), self.Value.Value, self.Usage) return fmt.Sprintf(fmtString, prefixedNames(df.Name), df.Value.Value, df.Usage)
} }
func eachName(longName string, fn func(string)) { func eachName(longName string, fn func(string)) {
@ -71,11 +71,11 @@ func eachName(longName string, fn func(string)) {
} }
} }
// called by cli library, grabs variable from environment (if in env) // Apply grabs variable from environment (if in env) and adds the variable to flagSet for parsing.
// and adds variable to flag set for parsing. // It is called by cli library.
func (self DirectoryFlag) Apply(set *flag.FlagSet) { func (df DirectoryFlag) Apply(set *flag.FlagSet) {
eachName(self.Name, func(name string) { eachName(df.Name, func(name string) {
set.Var(&self.Value, self.Name, self.Usage) set.Var(&df.Value, df.Name, df.Usage)
}) })
} }
@ -207,12 +207,12 @@ func prefixedNames(fullName string) (prefixed string) {
return return
} }
func (self DirectoryFlag) GetName() string { func (df DirectoryFlag) GetName() string {
return self.Name return df.Name
} }
func (self *DirectoryFlag) Set(value string) { func (df *DirectoryFlag) Set(value string) {
self.Value.Value = value df.Value.Value = value
} }
// Expands a file path // Expands a file path

View file

@ -112,7 +112,7 @@ func NewApp(gitCommit, usage string) *cli.App {
// are the same for all commands. // are the same for all commands.
var ( var (
// General settings // DataDirFlag is the flag for general settings.
DataDirFlag = DirectoryFlag{ DataDirFlag = DirectoryFlag{
Name: "datadir", Name: "datadir",
Usage: "Data directory for the databases and keystore", Usage: "Data directory for the databases and keystore",
@ -189,7 +189,7 @@ var (
Name: "lightkdf", Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
} }
// Dashboard settings // DashboardEnabledFlag is the flag for dashboard settings.
DashboardEnabledFlag = cli.BoolFlag{ DashboardEnabledFlag = cli.BoolFlag{
Name: "dashboard", Name: "dashboard",
Usage: "Enable the dashboard", Usage: "Enable the dashboard",
@ -209,7 +209,7 @@ var (
Usage: "Dashboard metrics collection refresh rate", Usage: "Dashboard metrics collection refresh rate",
Value: dashboard.DefaultConfig.Refresh, Value: dashboard.DefaultConfig.Refresh,
} }
// Ethash settings // EthashCacheDirFlag is the flag for ethash settings.
EthashCacheDirFlag = DirectoryFlag{ EthashCacheDirFlag = DirectoryFlag{
Name: "ethash.cachedir", Name: "ethash.cachedir",
Usage: "Directory to store the ethash verification caches (default = inside the datadir)", Usage: "Directory to store the ethash verification caches (default = inside the datadir)",
@ -239,7 +239,7 @@ var (
Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)", Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)",
Value: eth.DefaultConfig.Ethash.DatasetsOnDisk, Value: eth.DefaultConfig.Ethash.DatasetsOnDisk,
} }
// Transaction pool settings // TxPoolNoLocalsFlag is the flag for transaction pool settings.
TxPoolNoLocalsFlag = cli.BoolFlag{ TxPoolNoLocalsFlag = cli.BoolFlag{
Name: "txpool.nolocals", Name: "txpool.nolocals",
Usage: "Disables price exemptions for locally submitted transactions", Usage: "Disables price exemptions for locally submitted transactions",
@ -289,7 +289,7 @@ var (
Usage: "Maximum amount of time non-executable transaction are queued", Usage: "Maximum amount of time non-executable transaction are queued",
Value: eth.DefaultConfig.TxPool.Lifetime, Value: eth.DefaultConfig.TxPool.Lifetime,
} }
// Performance tuning settings // CacheFlag is the flag for performance tuning settings.
CacheFlag = cli.IntFlag{ CacheFlag = cli.IntFlag{
Name: "cache", Name: "cache",
Usage: "Megabytes of memory allocated to internal caching", Usage: "Megabytes of memory allocated to internal caching",
@ -310,7 +310,7 @@ var (
Usage: "Number of trie node generations to keep in memory", Usage: "Number of trie node generations to keep in memory",
Value: int(state.MaxTrieCacheGen), Value: int(state.MaxTrieCacheGen),
} }
// Miner settings // MiningEnabledFlag is the flag for miner settings.
MiningEnabledFlag = cli.BoolFlag{ MiningEnabledFlag = cli.BoolFlag{
Name: "mine", Name: "mine",
Usage: "Enable mining", Usage: "Enable mining",
@ -339,7 +339,7 @@ var (
Name: "extradata", Name: "extradata",
Usage: "Block extra data set by the miner (default = client version)", Usage: "Block extra data set by the miner (default = client version)",
} }
// Account settings // UnlockedAccountFlag is the flag for account settings.
UnlockedAccountFlag = cli.StringFlag{ UnlockedAccountFlag = cli.StringFlag{
Name: "unlock", Name: "unlock",
Usage: "Comma separated list of accounts to unlock", Usage: "Comma separated list of accounts to unlock",
@ -355,7 +355,7 @@ var (
Name: "vmdebug", Name: "vmdebug",
Usage: "Record information useful for VM and contract debugging", Usage: "Record information useful for VM and contract debugging",
} }
// Logging and debug settings // EthStatsURLFlag is the flag for logging and debug settings.
EthStatsURLFlag = cli.StringFlag{ EthStatsURLFlag = cli.StringFlag{
Name: "ethstats", Name: "ethstats",
Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)", Usage: "Reporting URL of a ethstats service (nodename:secret@host:port)",
@ -372,7 +372,7 @@ var (
Name: "nocompaction", Name: "nocompaction",
Usage: "Disables db compaction after import", Usage: "Disables db compaction after import",
} }
// RPC settings // RPCEnabledFlag is the flag for RPC settings.
RPCEnabledFlag = cli.BoolFlag{ RPCEnabledFlag = cli.BoolFlag{
Name: "rpc", Name: "rpc",
Usage: "Enable the HTTP-RPC server", Usage: "Enable the HTTP-RPC server",
@ -443,7 +443,7 @@ var (
Usage: "Comma separated list of JavaScript files to preload into the console", Usage: "Comma separated list of JavaScript files to preload into the console",
} }
// Network Settings // MaxPeersFlag is the flag for network settings.
MaxPeersFlag = cli.IntFlag{ MaxPeersFlag = cli.IntFlag{
Name: "maxpeers", Name: "maxpeers",
Usage: "Maximum number of network peers (network disabled if set to 0)", Usage: "Maximum number of network peers (network disabled if set to 0)",
@ -500,14 +500,14 @@ var (
Usage: "Restricts network communication to the given IP networks (CIDR masks)", Usage: "Restricts network communication to the given IP networks (CIDR masks)",
} }
// ATM the url is left to the user and deployment to // JSpathFlag leaves the url and deployment to the user (for now).
JSpathFlag = cli.StringFlag{ JSpathFlag = cli.StringFlag{
Name: "jspath", Name: "jspath",
Usage: "JavaScript root path for `loadScript`", Usage: "JavaScript root path for `loadScript`",
Value: ".", Value: ".",
} }
// Gas price oracle settings // GpoBlocksFlag is the flag for gas price oracle settings.
GpoBlocksFlag = cli.IntFlag{ GpoBlocksFlag = cli.IntFlag{
Name: "gpoblocks", Name: "gpoblocks",
Usage: "Number of recent blocks to check for gas prices", Usage: "Number of recent blocks to check for gas prices",