cmd

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(cfg *Cfg) (*exec.Cmd, error)

func IsSignaled

func IsSignaled(err error) bool

err is Cmd.Wait() or Cmd.Run() result error.

func MustStop

func MustStop(ctx context.Context, cmd *exec.Cmd) error

func Stop

func Stop(cmd *exec.Cmd) error

Types

type Cfg

type Cfg struct {
	Command    []string          `json:"command"    validate:"required,min=1" yaml:"command"`
	Env        map[string]string `json:"env"        yaml:"env"`
	RunAsUser  string            `json:"runAsUser"  yaml:"runAsUser"`
	WorkingDir string            `json:"workingDir" yaml:"workingDir"`
}

type Result

type Result struct {
	Stdout        []string `json:"stdout"`
	Stderr        []string `json:"stderr"`
	ExitCode      int      `json:"exitCode"`
	Pid           int      `json:"pid"`
	StartTimeNano int64    `json:"startTimeNano"`
	StopTimeNano  int64    `json:"stopTimeNano"`
	Signaled      bool     `json:"signaled"`
}

func Run

func Run(command ...string) (*Result, error)

func RunCmd

func RunCmd(ctx context.Context, beforeRun func(cmd *exec.Cmd), cmd *exec.Cmd) (*Result, error)

func RunRaw

func RunRaw(ctx context.Context, beforeRun func(cmd *exec.Cmd), cfg *Cfg) (*Result, error)

Jump to

Keyboard shortcuts

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