execwrapper

package
v1.119.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	// contains filtered or unexported fields
}

Cmd is an external command being prepared or run.

func CommandContext

func CommandContext(ctx context.Context, executable string, args ...string) *Cmd

CommandContext returns the Cmd struct to execute the named program with the given arguments.

func (*Cmd) Run

func (c *Cmd) Run() error

Run starts the specified command and waits for it to complete.

func (*Cmd) SetArgs added in v1.81.2

func (c *Cmd) SetArgs(args []string)

SetArgs sets arguments for the command including the command or executable path as the first argument.

func (*Cmd) SetErr

func (c *Cmd) SetErr(writer io.Writer)

SetErr sets the stderr of the command.

func (*Cmd) SetIn

func (c *Cmd) SetIn(reader io.Reader)

SetIn sets the stdin of the command.

func (*Cmd) SetOut

func (c *Cmd) SetOut(writer io.Writer)

SetOut sets the stdout of the command.

func (*Cmd) Start

func (c *Cmd) Start() error

Start starts the command but does not wait for it to complete. It returns an error if the command fails to start. The command must be started before calling Wait.

func (*Cmd) Wait

func (c *Cmd) Wait() error

Wait waits for the command to exit and waits for any copying to stdin or copying from stdout or stderr to complete. Start must be called before calling Wait.

type Command

type Command interface {
	// Start starts the command but does not wait for it to complete.
	// It returns an error if the command fails to start.
	// The command must be started before calling Wait.
	Start() error
	// Wait waits for the command to exit and waits for any copying to stdin or copying
	// from stdout or stderr to complete.
	// Start must be called before calling Wait.
	Wait() error
	// Run starts the specified command and waits for it to complete.
	Run() error
	// SetIn sets the stdin of the command.
	SetIn(io.Reader)
	// SetOut sets the stdout of the command.
	SetOut(io.Writer)
	// SetErr sets the stderr of the command.
	SetErr(io.Writer)
	// SetArgs sets arguments for the command including the command or executable path as the first argument.
	SetArgs([]string)
}

A Command is an external command being prepared or run. It tries to mimic the exec.Cmd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL