[release/1.4.6] cmd, console: split off the console into a reusable package
(cherry picked from commit ffaf58f0a9
)
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user