Add console support

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-12-14 13:31:30 -08:00
parent 25973db0c9
commit e480aedaea
2 changed files with 32 additions and 17 deletions

View file

@ -26,10 +26,16 @@ type State struct {
Status Status
}
type Console interface {
io.ReadWriter
io.Closer
}
type IO struct {
Stdin io.WriteCloser
Stdout io.ReadCloser
Stderr io.ReadCloser
Stdin io.WriteCloser
Stdout io.ReadCloser
Stderr io.ReadCloser
Console Console
}
func (i *IO) Close() error {
@ -39,10 +45,15 @@ func (i *IO) Close() error {
i.Stdout,
i.Stderr,
} {
if err := c.Close(); oerr == nil {
oerr = err
if c != nil {
if err := c.Close(); oerr == nil {
oerr = err
}
}
}
if i.Console != nil {
oerr = i.Console.Close()
}
return oerr
}