Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
c750ef09
Commit
c750ef09
authored
May 05, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: fix #853 colorize console output in windows
parent
ac85fdc7
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
763 additions
and
2 deletions
+763
-2
Godeps.json
Godeps/Godeps.json
+8
-0
README.md
...ps/_workspace/src/github.com/mattn/go-colorable/README.md
+42
-0
colorable_others.go
...ace/src/github.com/mattn/go-colorable/colorable_others.go
+16
-0
colorable_windows.go
...ce/src/github.com/mattn/go-colorable/colorable_windows.go
+594
-0
README.md
Godeps/_workspace/src/github.com/mattn/go-isatty/README.md
+37
-0
doc.go
Godeps/_workspace/src/github.com/mattn/go-isatty/doc.go
+2
-0
isatty_bsd.go
...s/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go
+17
-0
isatty_linux.go
..._workspace/src/github.com/mattn/go-isatty/isatty_linux.go
+17
-0
isatty_windows.go
...orkspace/src/github.com/mattn/go-isatty/isatty_windows.go
+18
-0
main.go
cmd/geth/main.go
+12
-2
No files found.
Godeps/Godeps.json
View file @
c750ef09
...
@@ -37,6 +37,14 @@
...
@@ -37,6 +37,14 @@
"ImportPath"
:
"github.com/kardianos/osext"
,
"ImportPath"
:
"github.com/kardianos/osext"
,
"Rev"
:
"ccfcd0245381f0c94c68f50626665eed3c6b726a"
"Rev"
:
"ccfcd0245381f0c94c68f50626665eed3c6b726a"
},
},
{
"ImportPath"
:
"github.com/mattn/go-colorable"
,
"Rev"
:
"043ae16291351db8465272edf465c9f388161627"
},
{
"ImportPath"
:
"github.com/mattn/go-isatty"
,
"Rev"
:
"fdbe02a1b44e75977b2690062b83cf507d70c013"
},
{
{
"ImportPath"
:
"github.com/obscuren/qml"
,
"ImportPath"
:
"github.com/obscuren/qml"
,
"Rev"
:
"c288002b52e905973b131089a8a7c761d4a2c36a"
"Rev"
:
"c288002b52e905973b131089a8a7c761d4a2c36a"
...
...
Godeps/_workspace/src/github.com/mattn/go-colorable/README.md
0 → 100644
View file @
c750ef09
# go-colorable
Colorable writer for windows.
For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
This package is possible to handle escape sequence for ansi color on windows.
## Too Bad!

## So Good!

## Usage
```
go
logrus
.
SetOutput
(
colorable
.
NewColorableStdout
())
logrus
.
Info
(
"succeeded"
)
logrus
.
Warn
(
"not correct"
)
logrus
.
Error
(
"something error"
)
logrus
.
Fatal
(
"panic"
)
```
You can compile above code on non-windows OSs.
## Installation
```
$ go get github.com/mattn/go-colorable
```
# License
MIT
# Author
Yasuhiro Matsumoto (a.k.a mattn)
Godeps/_workspace/src/github.com/mattn/go-colorable/colorable_others.go
0 → 100644
View file @
c750ef09
// +build !windows
package
colorable
import
(
"io"
"os"
)
func
NewColorableStdout
()
io
.
Writer
{
return
os
.
Stdout
}
func
NewColorableStderr
()
io
.
Writer
{
return
os
.
Stderr
}
Godeps/_workspace/src/github.com/mattn/go-colorable/colorable_windows.go
0 → 100644
View file @
c750ef09
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/mattn/go-isatty/README.md
0 → 100644
View file @
c750ef09
# go-isatty
isatty for golang
## Usage
```
go
package
main
import
(
"fmt"
"github.com/mattn/go-isatty"
"os"
)
func
main
()
{
if
isatty
.
IsTerminal
(
os
.
Stdout
.
Fd
())
{
fmt
.
Println
(
"Is Terminal"
)
}
else
{
fmt
.
Println
(
"Is Not Terminal"
)
}
}
```
## Installation
```
$ go get github.com/mattn/go-isatty
```
# License
MIT
# Author
Yasuhiro Matsumoto (a.k.a mattn)
Godeps/_workspace/src/github.com/mattn/go-isatty/doc.go
0 → 100644
View file @
c750ef09
// Package isatty implements interface to isatty
package
isatty
Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go
0 → 100644
View file @
c750ef09
// +build darwin freebsd
package
isatty
import
(
"syscall"
"unsafe"
)
const
ioctlReadTermios
=
syscall
.
TIOCGETA
// IsTerminal return true if the file descriptor is terminal.
func
IsTerminal
(
fd
uintptr
)
bool
{
var
termios
syscall
.
Termios
_
,
_
,
err
:=
syscall
.
Syscall6
(
syscall
.
SYS_IOCTL
,
fd
,
ioctlReadTermios
,
uintptr
(
unsafe
.
Pointer
(
&
termios
)),
0
,
0
,
0
)
return
err
==
0
}
Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_linux.go
0 → 100644
View file @
c750ef09
// +build linux
package
isatty
import
(
"syscall"
"unsafe"
)
const
ioctlReadTermios
=
syscall
.
TCGETS
// IsTerminal return true if the file descriptor is terminal.
func
IsTerminal
(
fd
uintptr
)
bool
{
var
termios
syscall
.
Termios
_
,
_
,
err
:=
syscall
.
Syscall6
(
syscall
.
SYS_IOCTL
,
fd
,
ioctlReadTermios
,
uintptr
(
unsafe
.
Pointer
(
&
termios
)),
0
,
0
,
0
)
return
err
==
0
}
Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_windows.go
0 → 100644
View file @
c750ef09
// +build windows
package
isatty
import
(
"syscall"
"unsafe"
)
var
kernel32
=
syscall
.
NewLazyDLL
(
"kernel32.dll"
)
var
procGetConsoleMode
=
kernel32
.
NewProc
(
"GetConsoleMode"
)
// IsTerminal return true if the file descriptor is terminal.
func
IsTerminal
(
fd
uintptr
)
bool
{
var
st
uint32
r
,
_
,
e
:=
syscall
.
Syscall
(
procGetConsoleMode
.
Addr
(),
2
,
fd
,
uintptr
(
unsafe
.
Pointer
(
&
st
)),
0
)
return
r
!=
0
&&
e
==
0
}
cmd/geth/main.go
View file @
c750ef09
...
@@ -23,14 +23,14 @@ package main
...
@@ -23,14 +23,14 @@ package main
import
(
import
(
"bufio"
"bufio"
"fmt"
"fmt"
"io"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path"
"runtime"
"runtime"
"strconv"
"strconv"
"time"
"time"
"path"
"github.com/codegangsta/cli"
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
...
@@ -41,6 +41,8 @@ import (
...
@@ -41,6 +41,8 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/peterh/liner"
"github.com/peterh/liner"
)
)
import
_
"net/http/pprof"
import
_
"net/http/pprof"
...
@@ -301,6 +303,14 @@ func run(ctx *cli.Context) {
...
@@ -301,6 +303,14 @@ func run(ctx *cli.Context) {
}
}
func
console
(
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
)
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
nodeNameVersion
,
ctx
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
ethereum
,
err
:=
eth
.
New
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment