github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/cli/command/stream.go (about) 1 package command 2 3 import ( 4 "github.com/docker/docker/pkg/term" 5 ) 6 7 // CommonStream is an input stream used by the DockerCli to read user input 8 type CommonStream struct { 9 fd uintptr 10 isTerminal bool 11 state *term.State 12 } 13 14 // FD returns the file descriptor number for this stream 15 func (s *CommonStream) FD() uintptr { 16 return s.fd 17 } 18 19 // IsTerminal returns true if this stream is connected to a terminal 20 func (s *CommonStream) IsTerminal() bool { 21 return s.isTerminal 22 } 23 24 // RestoreTerminal restores normal mode to the terminal 25 func (s *CommonStream) RestoreTerminal() { 26 if s.state != nil { 27 term.RestoreTerminal(s.fd, s.state) 28 } 29 } 30 31 // SetIsTerminal sets the boolean used for isTerminal 32 func (s *CommonStream) SetIsTerminal(isTerminal bool) { 33 s.isTerminal = isTerminal 34 }