@@ -28,42 +28,47 @@ import (
2828 "gopkg.in/urfave/cli.v1"
2929)
3030
31+ var (
32+ consoleFlags = []cli.Flag {utils .JSpathFlag , utils .ExecFlag , utils .PreloadJSFlag }
33+ )
34+
3135var (
3236 consoleCommand = cli.Command {
33- Action : localConsole ,
34- Name : "console" ,
35- Usage : "Start an interactive JavaScript environment" ,
36- ArgsUsage : "" , // TODO: Write this!
37- Category : "CONSOLE COMMANDS" ,
37+ Action : utils . MigrateFlags ( localConsole ) ,
38+ Name : "console" ,
39+ Usage : "Start an interactive JavaScript environment" ,
40+ Flags : append ( append ( nodeFlags , rpcFlags ... ), consoleFlags ... ),
41+ Category : "CONSOLE COMMANDS" ,
3842 Description : `
3943The Geth console is an interactive shell for the JavaScript runtime environment
4044which exposes a node admin interface as well as the Ðapp JavaScript API.
41- See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console
42- ` ,
45+ See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.` ,
4346 }
47+
4448 attachCommand = cli.Command {
45- Action : remoteConsole ,
49+ Action : utils . MigrateFlags ( remoteConsole ) ,
4650 Name : "attach" ,
4751 Usage : "Start an interactive JavaScript environment (connect to node)" ,
48- ArgsUsage : "" , // TODO: Write this!
52+ ArgsUsage : "[endpoint]" ,
53+ Flags : append (consoleFlags , utils .DataDirFlag ),
4954 Category : "CONSOLE COMMANDS" ,
5055 Description : `
5156The Geth console is an interactive shell for the JavaScript runtime environment
5257which exposes a node admin interface as well as the Ðapp JavaScript API.
5358See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.
54- This command allows to open a console on a running geth node.
55- ` ,
59+ This command allows to open a console on a running geth node.` ,
5660 }
61+
5762 javascriptCommand = cli.Command {
58- Action : ephemeralConsole ,
63+ Action : utils . MigrateFlags ( ephemeralConsole ) ,
5964 Name : "js" ,
6065 Usage : "Execute the specified JavaScript files" ,
61- ArgsUsage : "" , // TODO: Write this!
66+ ArgsUsage : "<jsfile> [jsfile...]" ,
67+ Flags : append (nodeFlags , consoleFlags ... ),
6268 Category : "CONSOLE COMMANDS" ,
6369 Description : `
6470The JavaScript VM exposes a node admin interface as well as the Ðapp
65- JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console
66- ` ,
71+ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console` ,
6772 }
6873)
6974
@@ -81,11 +86,12 @@ func localConsole(ctx *cli.Context) error {
8186 utils .Fatalf ("Failed to attach to the inproc geth: %v" , err )
8287 }
8388 config := console.Config {
84- DataDir : node . DataDir ( ),
89+ DataDir : utils . MakeDataDir ( ctx ),
8590 DocRoot : ctx .GlobalString (utils .JSpathFlag .Name ),
8691 Client : client ,
8792 Preload : utils .MakeConsolePreloads (ctx ),
8893 }
94+
8995 console , err := console .New (config )
9096 if err != nil {
9197 utils .Fatalf ("Failed to start the JavaScript console: %v" , err )
@@ -118,17 +124,18 @@ func remoteConsole(ctx *cli.Context) error {
118124 Client : client ,
119125 Preload : utils .MakeConsolePreloads (ctx ),
120126 }
127+
121128 console , err := console .New (config )
122129 if err != nil {
123130 utils .Fatalf ("Failed to start the JavaScript console: %v" , err )
124131 }
125132 defer console .Stop (false )
126133
127- // If only a short execution was requested, evaluate and return
128134 if script := ctx .GlobalString (utils .ExecFlag .Name ); script != "" {
129135 console .Evaluate (script )
130136 return nil
131137 }
138+
132139 // Otherwise print the welcome screen and enter interactive mode
133140 console .Welcome ()
134141 console .Interactive ()
@@ -151,7 +158,7 @@ func dialRPC(endpoint string) (*rpc.Client, error) {
151158}
152159
153160// ephemeralConsole starts a new geth node, attaches an ephemeral JavaScript
154- // console to it, and each of the files specified as arguments and tears the
161+ // console to it, executes each of the files specified as arguments and tears
155162// everything down.
156163func ephemeralConsole (ctx * cli.Context ) error {
157164 // Create and start the node based on the CLI flags
@@ -165,11 +172,12 @@ func ephemeralConsole(ctx *cli.Context) error {
165172 utils .Fatalf ("Failed to attach to the inproc geth: %v" , err )
166173 }
167174 config := console.Config {
168- DataDir : node . DataDir ( ),
175+ DataDir : utils . MakeDataDir ( ctx ),
169176 DocRoot : ctx .GlobalString (utils .JSpathFlag .Name ),
170177 Client : client ,
171178 Preload : utils .MakeConsolePreloads (ctx ),
172179 }
180+
173181 console , err := console .New (config )
174182 if err != nil {
175183 utils .Fatalf ("Failed to start the JavaScript console: %v" , err )
0 commit comments