-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
158 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ processes: | |
|
||
server: | ||
command: "python3 -m http.server 4040" | ||
is_tty: true | ||
|
||
kcalc: | ||
command: "kcalc" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"github.com/creack/pty" | ||
"golang.org/x/term" | ||
"io" | ||
"os" | ||
) | ||
|
||
type CmdWrapperPty struct { | ||
*CmdWrapper | ||
ptmx *os.File | ||
} | ||
|
||
func (c *CmdWrapperPty) Start() (err error) { | ||
if c.ptmx != nil { | ||
return nil | ||
} | ||
c.ptmx, err = pty.Start(c.cmd) | ||
// No need to capture/restore old state, because we close the PTY when we're done. | ||
_, err = term.MakeRaw(int(c.ptmx.Fd())) | ||
if err != nil { | ||
return fmt.Errorf("error putting PTY into raw mode: %w", err) | ||
} | ||
return err | ||
} | ||
|
||
func (c *CmdWrapperPty) Wait() error { | ||
defer c.ptmx.Close() | ||
return c.cmd.Wait() | ||
} | ||
|
||
func (c *CmdWrapperPty) StdoutPipe() (io.ReadCloser, error) { | ||
if c.ptmx == nil { | ||
c.Start() | ||
} | ||
return c.ptmx, nil | ||
} | ||
|
||
func (c *CmdWrapperPty) StderrPipe() (io.ReadCloser, error) { | ||
return nil, fmt.Errorf("not supported in PTY") | ||
} | ||
|
||
func (c *CmdWrapperPty) SetCmdArgs() { | ||
//c.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package command | ||
|
||
import "io" | ||
|
||
type Commander interface { | ||
Stop(sig int, _parentOnly bool) error | ||
SetCmdArgs() | ||
Start() error | ||
Run() error | ||
Wait() error | ||
ExitCode() int | ||
Pid() int | ||
StdoutPipe() (io.ReadCloser, error) | ||
StderrPipe() (io.ReadCloser, error) | ||
AttachIo() | ||
SetEnv(env []string) | ||
SetDir(dir string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1eba53f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Thanks so much :)