diff options
author | Bas van Kervel <bas@ethdev.com> | 2015-06-19 00:23:13 +0800 |
---|---|---|
committer | Bas van Kervel <bas@ethdev.com> | 2015-06-22 15:17:09 +0800 |
commit | f20256377731097c9478ede750efffd46d83b494 (patch) | |
tree | 25ea2b0de5382ed25dde5ff2021214625f3e9865 /cmd/geth/main.go | |
parent | 36a6b16a3bec15131318ebed1c8c2f9204a5a328 (diff) | |
download | go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.gz go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.bz2 go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.lz go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.xz go-tangerine-f20256377731097c9478ede750efffd46d83b494.tar.zst go-tangerine-f20256377731097c9478ede750efffd46d83b494.zip |
added attach over ipc command
Diffstat (limited to 'cmd/geth/main.go')
-rw-r--r-- | cmd/geth/main.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 5c4c33cea..f1e8ace3d 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -204,6 +204,16 @@ nodes. The Geth console is an interactive shell for the JavaScript runtime environment which exposes a node admin interface as well as the Ðapp JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console +`}, + { + Action: attach, + Name: "attach", + Usage: `Geth Console: interactive JavaScript environment`, + Description: ` +The Geth console is an interactive shell for the JavaScript runtime environment +which exposes a node admin interface as well as the Ðapp JavaScript API. +See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console. +This command allows to open a console on a running geth node. `, }, { @@ -297,6 +307,40 @@ func run(ctx *cli.Context) { ethereum.WaitForShutdown() } +func attach(ctx *cli.Context) { + // Wrap the standard output with a colorified stream (windows) + if isatty.IsTerminal(os.Stdout.Fd()) { + if pr, pw, err := os.Pipe(); err == nil { + go io.Copy(colorable.NewColorableStdout(), pr) + os.Stdout = pw + } + } + + var client comms.EthereumClient + var err error + if ctx.Args().Present() { + client, err = comms.ClientFromEndpoint(ctx.Args().First(), codec.JSON) + } else { + cfg := comms.IpcConfig{ + Endpoint: ctx.GlobalString(utils.IPCPathFlag.Name), + } + client, err = comms.NewIpcClient(cfg, codec.JSON) + } + + if err != nil { + utils.Fatalf("Unable to attach to geth node - %v", err) + } + + repl := newLightweightJSRE( + ctx.String(utils.JSpathFlag.Name), + client, + true, + nil) + + repl.welcome() + repl.interactive() +} + func console(ctx *cli.Context) { // Wrap the standard output with a colorified stream (windows) if isatty.IsTerminal(os.Stdout.Fd()) { @@ -323,6 +367,8 @@ func console(ctx *cli.Context) { true, nil, ) + + repl.welcome() repl.interactive() ethereum.Stop() |