Skip to content

Commit

Permalink
feat(term): xpty: add godocs
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed May 8, 2024
1 parent eb4e1d7 commit e8d8b6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion exp/term/xpty/conpty.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (c *ConPty) Name() string {
}

// Start starts a command on the ConPty.
// This is a wrapper around conpty.Spawn.
func (c *ConPty) Start(cmd *exec.Cmd) error {
return c.start(cmd)
}

17 changes: 17 additions & 0 deletions exp/term/xpty/xpty.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ type Options struct {
type PtyOption func(o Options)

// NewPty creates a new PTY.
//
// The returned PTY will be a Unix PTY on Unix systems and a ConPTY on Windows.
// The width and height parameters specify the initial size of the PTY.
// You can pass additional options to the PTY by passing PtyOptions.
//
// pty, err := xpty.NewPty(80, 24)
// if err != nil {
// // handle error
// }
//
// defer pty.Close() // Make sure to close the PTY when done.
// switch pty := pty.(type) {
// case xpty.UnixPty:
// // Unix PTY
// case xpty.ConPty:
// // ConPTY
// }
func NewPty(width, height int, opts ...PtyOption) (Pty, error) {
if runtime.GOOS == "windows" {
return NewConPty(width, height, opts...)
Expand Down

0 comments on commit e8d8b6e

Please sign in to comment.