mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
* Add ssh tests for longoutput, orphan Signed-off-by: Spike Curtis <spike@coder.com> * PTY/SSH tests & improvements Signed-off-by: Spike Curtis <spike@coder.com> * Fix some tests Signed-off-by: Spike Curtis <spike@coder.com> * Fix linting Signed-off-by: Spike Curtis <spike@coder.com> * fmt Signed-off-by: Spike Curtis <spike@coder.com> * Fix windows test Signed-off-by: Spike Curtis <spike@coder.com> * Windows copy test Signed-off-by: Spike Curtis <spike@coder.com> * WIP Windows pty handling Signed-off-by: Spike Curtis <spike@coder.com> * Fix truncation tests Signed-off-by: Spike Curtis <spike@coder.com> * Appease linter/fmt Signed-off-by: Spike Curtis <spike@coder.com> * Fix typo Signed-off-by: Spike Curtis <spike@coder.com> * Rework truncation test to not assume OS buffers Signed-off-by: Spike Curtis <spike@coder.com> * Disable orphan test on Windows --- uses sh Signed-off-by: Spike Curtis <spike@coder.com> * agent_test running SSH in pty use ptytest.Start Signed-off-by: Spike Curtis <spike@coder.com> * More detail about closing pseudoconsole on windows Signed-off-by: Spike Curtis <spike@coder.com> * Code review fixes Signed-off-by: Spike Curtis <spike@coder.com> * Rearrange ptytest method order Signed-off-by: Spike Curtis <spike@coder.com> * Protect pty.Resize on windows from races Signed-off-by: Spike Curtis <spike@coder.com> * Fix windows bugs Signed-off-by: Spike Curtis <spike@coder.com> * PTY doesn't extend PTYCmd Signed-off-by: Spike Curtis <spike@coder.com> * Fix windows types Signed-off-by: Spike Curtis <spike@coder.com> --------- Signed-off-by: Spike Curtis <spike@coder.com>
26 lines
657 B
Go
26 lines
657 B
Go
package pty
|
|
|
|
import (
|
|
"os/exec"
|
|
)
|
|
|
|
// StartOption represents a configuration option passed to Start.
|
|
type StartOption func(*startOptions)
|
|
|
|
type startOptions struct {
|
|
ptyOpts []Option
|
|
}
|
|
|
|
// WithPTYOption applies the given options to the underlying PTY.
|
|
func WithPTYOption(opts ...Option) StartOption {
|
|
return func(o *startOptions) {
|
|
o.ptyOpts = append(o.ptyOpts, opts...)
|
|
}
|
|
}
|
|
|
|
// Start the command in a TTY. The calling code must not use cmd after passing it to the PTY, and
|
|
// instead rely on the returned Process to manage the command/process.
|
|
func Start(cmd *exec.Cmd, opt ...StartOption) (PTYCmd, Process, error) {
|
|
return startPty(cmd, opt...)
|
|
}
|