forked from cloudfoundry-community/cloudfoundry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.go
48 lines (36 loc) · 1.16 KB
/
helper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package terminal
import (
"io"
"github.com/docker/docker/pkg/term"
)
//go:generate counterfeiter . TerminalHelper
type TerminalHelper interface {
StdStreams() (stdin io.ReadCloser, stdout io.Writer, stderr io.Writer)
GetFdInfo(in interface{}) (fd uintptr, isTerminal bool)
SetRawTerminal(fd uintptr) (*term.State, error)
RestoreTerminal(fd uintptr, state *term.State) error
IsTerminal(fd uintptr) bool
GetWinsize(fd uintptr) (*term.Winsize, error)
}
type terminalHelper struct{}
func DefaultHelper() TerminalHelper {
return &terminalHelper{}
}
func (t *terminalHelper) StdStreams() (io.ReadCloser, io.Writer, io.Writer) {
return term.StdStreams()
}
func (t *terminalHelper) GetFdInfo(in interface{}) (uintptr, bool) {
return term.GetFdInfo(in)
}
func (t *terminalHelper) SetRawTerminal(fd uintptr) (*term.State, error) {
return term.SetRawTerminal(fd)
}
func (t *terminalHelper) RestoreTerminal(fd uintptr, state *term.State) error {
return term.RestoreTerminal(fd, state)
}
func (t *terminalHelper) IsTerminal(fd uintptr) bool {
return term.IsTerminal(fd)
}
func (t *terminalHelper) GetWinsize(fd uintptr) (*term.Winsize, error) {
return term.GetWinsize(fd)
}