2022-02-17 16:44:49 +00:00
|
|
|
package pty
|
|
|
|
|
2022-02-19 05:13:32 +00:00
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
)
|
2022-02-17 16:44:49 +00:00
|
|
|
|
2022-09-12 16:27:51 +00:00
|
|
|
// 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...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-27 19:23:28 +00:00
|
|
|
// 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.
|
2023-04-24 10:53:57 +00:00
|
|
|
func Start(cmd *exec.Cmd, opt ...StartOption) (PTYCmd, Process, error) {
|
2022-09-12 16:27:51 +00:00
|
|
|
return startPty(cmd, opt...)
|
2022-02-17 16:44:49 +00:00
|
|
|
}
|