added windows compilation support for PTY
This commit is contained in:
parent
9267fbc857
commit
bc51750141
|
@ -0,0 +1,14 @@
|
|||
package data
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
startupTimeout = 200 * time.Millisecond
|
||||
minAwaitTimeout = 100 * time.Millisecond
|
||||
maxAwaitTimeout = 1 * time.Second
|
||||
)
|
||||
|
||||
type InteractiveShell interface {
|
||||
init() error
|
||||
execute() (string, error)
|
||||
}
|
|
@ -25,7 +25,11 @@ func (s *BasicInteractiveShell) init() error {
|
|||
|
||||
cmd := exec.Command("sh", "-c", s.item.initScripts[0])
|
||||
enrichEnvVariables(cmd, s.variables)
|
||||
cmd.Wait()
|
||||
|
||||
err := cmd.Wait()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
|
@ -78,6 +82,10 @@ func (s *BasicInteractiveShell) init() error {
|
|||
|
||||
func (s *BasicInteractiveShell) execute() (string, error) {
|
||||
|
||||
if s.stdin == nil {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
_, err := io.WriteString(s.stdin, fmt.Sprintf(" %s\n", s.item.sampleScript))
|
||||
if err != nil {
|
||||
s.errCount++
|
|
@ -12,15 +12,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
startupTimeout = 200 * time.Millisecond
|
||||
minAwaitTimeout = 100 * time.Millisecond
|
||||
maxAwaitTimeout = 1 * time.Second
|
||||
)
|
||||
|
||||
/**
|
||||
* Experimental
|
||||
*/
|
||||
type PtyInteractiveShell struct {
|
||||
item *Item
|
||||
variables []string
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PtyInteractiveShell struct {
|
||||
item *Item
|
||||
variables []string
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func (s *PtyInteractiveShell) init() error {
|
||||
return errors.New("PTY mode is not supported on Windows")
|
||||
}
|
||||
|
||||
func (s *PtyInteractiveShell) execute() (string, error) {
|
||||
return "", errors.New("PTY mode is not supported on Windows")
|
||||
}
|
|
@ -18,8 +18,8 @@ type Item struct {
|
|||
color *ui.Color
|
||||
rateMs int
|
||||
pty bool
|
||||
basicShell *BasicInteractiveShell
|
||||
ptyShell *PtyInteractiveShell
|
||||
basicShell InteractiveShell
|
||||
ptyShell InteractiveShell
|
||||
}
|
||||
|
||||
func NewItems(cfgs []config.Item, rateMs int) []*Item {
|
||||
|
|
Loading…
Reference in New Issue