aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/flags.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-05-06 17:40:23 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-05-30 22:25:23 +0800
commitffaf58f0a98bd987bbe76e8669bb22c405dcd62a (patch)
tree4cd484504d4a7089cfd85d22a2a9fa62c79abb7d /cmd/utils/flags.go
parentab664c7e17009729d1083d8d4f7c37eb387012d3 (diff)
downloadgo-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.tar
go-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.tar.gz
go-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.tar.bz2
go-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.tar.lz
go-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.tar.xz
go-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.tar.zst
go-tangerine-ffaf58f0a98bd987bbe76e8669bb22c405dcd62a.zip
cmd, console: split off the console into a reusable package
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r--cmd/utils/flags.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 43dbc37f7..c476e1c77 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -302,7 +302,7 @@ var (
Name: "exec",
Usage: "Execute JavaScript statement (only in combination with console/attach)",
}
- PreLoadJSFlag = cli.StringFlag{
+ PreloadJSFlag = cli.StringFlag{
Name: "preload",
Usage: "Comma separated list of JavaScript files to preload into the console",
}
@@ -864,3 +864,20 @@ func MakeChain(ctx *cli.Context) (chain *core.BlockChain, chainDb ethdb.Database
}
return chain, chainDb
}
+
+// MakeConsolePreloads retrieves the absolute paths for the console JavaScript
+// scripts to preload before starting.
+func MakeConsolePreloads(ctx *cli.Context) []string {
+ // Skip preloading if there's nothing to preload
+ if ctx.GlobalString(PreloadJSFlag.Name) == "" {
+ return nil
+ }
+ // Otherwise resolve absolute paths and return them
+ preloads := []string{}
+
+ assets := ctx.GlobalString(JSpathFlag.Name)
+ for _, file := range strings.Split(ctx.GlobalString(PreloadJSFlag.Name), ",") {
+ preloads = append(preloads, common.AbsolutePath(assets, strings.TrimSpace(file)))
+ }
+ return preloads
+}