Documentation
¶
Index ¶
- Variables
- func NewCmdTree(root *Cmd, subcommands ...*Cmd) *cmdTree
- type Cmd
- func (c *Cmd) Done() <-chan struct{}
- func (c *Cmd) Name() string
- func (c *Cmd) Restart() error
- func (c *Cmd) Running() bool
- func (c *Cmd) Shutdown() error
- func (c *Cmd) Start() error
- func (c *Cmd) Stderr() io.Reader
- func (c *Cmd) Stdin() io.Writer
- func (c *Cmd) Stdout() io.Reader
- func (c *Cmd) Stop() error
- func (c *Cmd) Wait() error
- type Option
Constants ¶
This section is empty.
Variables ¶
var (
ErrCmdAlreadyStarted = errors.New("cmd already started")
)
Functions ¶
func NewCmdTree ¶
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd allows to control a process started through os.Exec with additional start, stop and restart capabilities, and provides readers/writers for the command's outputs and input, respectively.
func (*Cmd) Restart ¶
Restart first interrupts the command if it's already running, and then re-runs the command.
func (*Cmd) Start ¶
Start starts the command if it's not already running. It will be a noop if it is. It also spins up a goroutine that will receive any error occurred during the command's exit.
func (*Cmd) Stderr ¶
Stderr returns a reader to the command's stderr. The reader will return an io.EOF error if the command exits.
func (*Cmd) Stdin ¶
Stdin returns a writer to the command's stdin. The writer will be closed if the command has exited by the time this function is called.
func (*Cmd) Stdout ¶
Stdout returns a reader to the command's stdout. The reader will return an io.EOF error if the command exits.