diff options
Diffstat (limited to 'cmd/utils/flags.go')
-rw-r--r-- | cmd/utils/flags.go | 19 |
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 +} |