Documentation
¶
Overview ¶
Package sh runs external tools (kubectl, docker, ssh, ...) with errors that carry their stderr.
Index ¶
- func Alive(pid int) bool
- func Detach(cmd *exec.Cmd)
- func Detached(cmd *exec.Cmd)
- func FreeBytes(path string) (uint64, error)
- func Have(name string) bool
- func Hint(text string) string
- func Interrupt(pid int) error
- func KillGroup(cmd *exec.Cmd)
- func OwnGroup(cmd *exec.Cmd)
- func StopGroup(pid int, force bool)
- func TiedToParent(cmd *exec.Cmd)
- func WithHint(text string) string
- type Cmd
- func (c *Cmd) Attach(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Cmd) Exec(ctx context.Context) *exec.Cmd
- func (c *Cmd) Lines(ctx context.Context) (<-chan string, error)
- func (c *Cmd) Output(ctx context.Context) ([]byte, error)
- func (c *Cmd) Run(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Detach ¶
Detach starts cmd in a session of its own, so it outlives rig and a group signal reaches all of it.
func Detached ¶
Detached runs cmd in a session of its own, without the terminal: a background task must not query the terminal, whose answers would land in the TUI's input. KillGroup stops it.
func Hint ¶
Hint is what to do about an error a new setup typically hits (a tool not installed, Docker not running, no Kubernetes cluster), "" when it is none of those.
func OwnGroup ¶
OwnGroup puts cmd in a process group of its own, so KillGroup stops what it started too (go test's test binaries).
func StopGroup ¶
StopGroup asks the process group led by pid to stop (SIGTERM), or forces it (SIGKILL).
func TiedToParent ¶
TiedToParent makes cmd die with this process, even when this process is killed: a port-forward must not outlive the rig that opened it.
Types ¶
type Cmd ¶
func (*Cmd) Attach ¶
Attach runs the command on the given streams (an interactive shell, a live log), or, when the caller asked to capture it, hands the command back to run on the caller's terminal.
func (*Cmd) Exec ¶
Exec is the *exec.Cmd form, for front ends that hand the terminal over (bubbletea's ExecProcess).
func (*Cmd) Lines ¶
Lines streams stdout line by line until the command exits or ctx ends; the channel then closes.