aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index e9b0d86a4..9e80bba60 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -647,7 +647,7 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
}
}
-// MakePasswordList reads password lines from the file specified by --password.
+// MakePasswordList reads password lines from the file specified by the global --password flag.
func MakePasswordList(ctx *cli.Context) []string {
path := ctx.GlobalString(PasswordFileFlag.Name)
if path == "" {
@@ -979,3 +979,27 @@ func MakeConsolePreloads(ctx *cli.Context) []string {
}
return preloads
}
+
+// MigrateFlags sets the global flag from a local flag when it's set.
+// This is a temporary function used for migrating old command/flags to the
+// new format.
+//
+// e.g. geth account new --keystore /tmp/mykeystore --lightkdf
+//
+// is equivalent after calling this method with:
+//
+// geth --keystore /tmp/mykeystore --lightkdf account new
+//
+// This allows the use of the existing configuration functionality.
+// When all flags are migrated this function can be removed and the existing
+// configuration functionality must be changed that is uses local flags
+func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error {
+ return func(ctx *cli.Context) error {
+ for _, name := range ctx.FlagNames() {
+ if ctx.IsSet(name) {
+ ctx.GlobalSet(name, ctx.String(name))
+ }
+ }
+ return action(ctx)
+ }
+}