execx

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pipe

func Pipe(cmds []*exec.Cmd, stdin io.Reader, stdout, stderr io.Writer) error

func Run

func Run(cmd *exec.Cmd) (int, error)

func RunPipe

func RunPipe(cmds []*exec.Cmd) (int, error)

Types

type Arguments

type Arguments []string

func Parse

func Parse(input string) ([]Arguments, error)

func (*Arguments) Add

func (c *Arguments) Add(arg string)

func (Arguments) Cmd added in v0.0.2

func (c Arguments) Cmd() (*Cmd, error)

func (Arguments) Get

func (c Arguments) Get(n int) string

func (Arguments) String

func (c Arguments) String() string

type Cmd

type Cmd struct {
	Env  []string
	Cmd  string
	Args []string
	Dir  string
}

func (*Cmd) Command

func (c *Cmd) Command() *exec.Cmd

func (*Cmd) CommandContext

func (c *Cmd) CommandContext(ctx context.Context) *exec.Cmd

type CmdLogger

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

CmdLogger captures the Stdout and Stderr output of a process, writes it to the console and exposes functions to returns the most relevant output based on the status code:

  • stdout if the process was successful
  • stderr if the process failed and produced an error message
  • stdout if the process failed but there is no stderr output

func Log

func Log(cmd *exec.Cmd, maxLen int) *CmdLogger

func (*CmdLogger) Output

func (l *CmdLogger) Output() (ProcessOutput, error)

Output returns the most relevant output based on the exit code.

type ProcessOutput

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

ProcessOutput represents lines printed by a process.

func (*ProcessOutput) Empty

func (s *ProcessOutput) Empty() bool

func (*ProcessOutput) Get

func (s *ProcessOutput) Get() (output string, tail bool, err error)

Jump to

Keyboard shortcuts

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