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])
|
cmd := exec.Command("sh", "-c", s.item.initScripts[0])
|
||||||
enrichEnvVariables(cmd, s.variables)
|
enrichEnvVariables(cmd, s.variables)
|
||||||
cmd.Wait()
|
|
||||||
|
err := cmd.Wait()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -78,6 +82,10 @@ func (s *BasicInteractiveShell) init() error {
|
||||||
|
|
||||||
func (s *BasicInteractiveShell) execute() (string, 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))
|
_, err := io.WriteString(s.stdin, fmt.Sprintf(" %s\n", s.item.sampleScript))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.errCount++
|
s.errCount++
|
|
@ -12,15 +12,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
startupTimeout = 200 * time.Millisecond
|
|
||||||
minAwaitTimeout = 100 * time.Millisecond
|
|
||||||
maxAwaitTimeout = 1 * time.Second
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Experimental
|
|
||||||
*/
|
|
||||||
type PtyInteractiveShell struct {
|
type PtyInteractiveShell struct {
|
||||||
item *Item
|
item *Item
|
||||||
variables []string
|
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
|
color *ui.Color
|
||||||
rateMs int
|
rateMs int
|
||||||
pty bool
|
pty bool
|
||||||
basicShell *BasicInteractiveShell
|
basicShell InteractiveShell
|
||||||
ptyShell *PtyInteractiveShell
|
ptyShell InteractiveShell
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewItems(cfgs []config.Item, rateMs int) []*Item {
|
func NewItems(cfgs []config.Item, rateMs int) []*Item {
|
||||||
|
|
Loading…
Reference in New Issue