Skip to content

Commit

Permalink
fix: fix some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Apr 5, 2022
1 parent 9dc7917 commit b2bbcd3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tea.go
Expand Up @@ -245,7 +245,7 @@ func HideCursor() Msg {
return hideCursorMsg{}
}

// Exec runs the given *exec.Cmd in a blocking fashion, effectively pausing the
// Exec runs the given ExecCommand in a blocking fashion, effectively pausing the
// Program while the command is running. After the *exec.Cmd exists the Program
// resumes. It's useful for spawning other interactive applications such as
// editors and shells from within a Program.
Expand All @@ -258,13 +258,13 @@ func HideCursor() Msg {
//
// c := exec.Command("vim", "file.txt")
//
// cmd := Exec(c, func(err error) Msg {
// cmd := Exec(WrapExecCommand(c), func(err error) Msg {
// return VimFinishedMsg{err: error}
// })
//
// Or, if you don't care about errors you could simply:
//
// cmd := Exec(exec.Command("vim", "file.txt"), nil)
// cmd := Exec(WrapExecCommand(exec.Command("vim", "file.txt")), nil)
//
// For non-interactive i/o you should use a Cmd (that is, a tea.Cmd).
func Exec(c ExecCommand, fn ExecCallback) Cmd {
Expand All @@ -277,7 +277,7 @@ func Exec(c ExecCommand, fn ExecCallback) Cmd {
// with an error, which may or may not be nil.
type ExecCallback func(error) Msg

// execMsg is used internally to run an *exec.Cmd sent with Exec.
// execMsg is used internally to run an ExecCommand sent with Exec.
type execMsg struct {
cmd ExecCommand
fn ExecCallback
Expand Down Expand Up @@ -770,20 +770,23 @@ type osExecCommand struct{ *exec.Cmd }

// SetStdin to comply with the Command interface.
func (c *osExecCommand) SetStdin(r io.Reader) {
// If unset, have the command use the same input as the terminal.
if c.Stdin == nil {
c.Stdin = r
}
}

// SetStdout to comply with the Command interface.
func (c *osExecCommand) SetStdout(w io.Writer) {
// If unset, have the command use the same output as the terminal.
if c.Stdout == nil {
c.Stdout = w
}
}

// SetStderr to comply with the Command interface.
func (c *osExecCommand) SetStderr(w io.Writer) {
// If unset, use stderr for the command's stderr
if c.Stderr == nil {
c.Stderr = w
}
Expand All @@ -799,11 +802,8 @@ func (p *Program) exec(c ExecCommand, fn ExecCallback) {
return
}

// If unset, have the command use the same input and output
// as the terminal.
c.SetStdin(p.input)
c.SetStdout(p.output)
// If unset, use stderr for the command's stderr
c.SetStderr(os.Stderr)

// Execute system command.
Expand Down

0 comments on commit b2bbcd3

Please sign in to comment.