aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-05 19:50:48 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-05 19:50:48 +0800
commit2e9ed6f7aa84519a5d209dfc9649a0381e89e8ee (patch)
tree54fbe761882dd7c6eba364ecd93a2fb32ae68ab5 /cmd/geth
parentac85fdc75edfaf999a7b2d25c5313c1b3eeb86ad (diff)
parentc750ef09e1571fbdb36d408ff894ed2bbcc80014 (diff)
downloaddexon-2e9ed6f7aa84519a5d209dfc9649a0381e89e8ee.tar.gz
dexon-2e9ed6f7aa84519a5d209dfc9649a0381e89e8ee.tar.zst
dexon-2e9ed6f7aa84519a5d209dfc9649a0381e89e8ee.zip
Merge pull request #856 from karalabe/windows-console-color-fix
cmd/geth: colorize console output in windows
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 0f5ebf5be..e00b139c0 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -23,14 +23,14 @@ package main
import (
"bufio"
"fmt"
+ "io"
"io/ioutil"
"os"
+ "path"
"runtime"
"strconv"
"time"
- "path"
-
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
@@ -41,6 +41,8 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
+ "github.com/mattn/go-colorable"
+ "github.com/mattn/go-isatty"
"github.com/peterh/liner"
)
import _ "net/http/pprof"
@@ -301,6 +303,14 @@ func run(ctx *cli.Context) {
}
func console(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
+ }
+ }
+
cfg := utils.MakeEthConfig(ClientIdentifier, nodeNameVersion, ctx)
ethereum, err := eth.New(cfg)
if err != nil {