Skip to content

Commit

Permalink
docs: document command better
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Jan 30, 2024
1 parent af8b357 commit 502154d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@ import (
//
// If the current session does not have a PTY, it sets them to the session
// itself.
//
// Note that due to the way Windows conpty works, using this on a Windows
// server in conjunction with the AllocatePty option is not recommended,
// as once the command finishes, the PTY will be killed too.
func CommandContext(ctx context.Context, s ssh.Session, name string, args ...string) *Cmd {
cmd := exec.CommandContext(ctx, name, args...)
return &Cmd{s, cmd}
}

// Command sets stdin, stdout, and stderr to the current session's PTY slave.
// Command sets stdin, stdout, and stderr to the current session's PTY.
//
// If the current session does not have a PTY, it sets them to the session
// itself.
//
// This will call CommandContext using the session's Context.
// This will use the session's context as the context for exec.Command.
//
// Note that due to the way Windows conpty works, using this on a Windows
// server in conjunction with the AllocatePty option is not recommended,
// as once the command finishes, the PTY will be killed too.
func Command(s ssh.Session, name string, args ...string) *Cmd {
return CommandContext(s.Context(), s, name, args...)
}
Expand Down

0 comments on commit 502154d

Please sign in to comment.