command

package
v0.0.0-...-66acf6f Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: BSD-3-Clause, MIT Imports: 8 Imported by: 0

README

Command

Executes a command with a timeout.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecForJSON

func ExecForJSON(command string, args []string, obj interface{}, timeout time.Duration, log Log) error

ExecForJSON runs a command (with timeout) expecting JSON output with obj interface

Types

type Log

type Log interface {
	Debugf(s string, args ...interface{})
	Infof(s string, args ...interface{})
	Warningf(s string, args ...interface{})
	Errorf(s string, args ...interface{})
}

Log is the logging interface for the command package

type Program

type Program struct {
	Path string
	Args []string
}

Program is a program at path with arguments

func (Program) ArgsWith

func (p Program) ArgsWith(args []string) []string

ArgsWith returns program args with passed in args

type Result

type Result struct {
	Stdout  bytes.Buffer
	Stderr  bytes.Buffer
	Process *os.Process
}

Result is the result of running a command

func Exec

func Exec(name string, args []string, timeout time.Duration, log Log) (Result, error)

Exec runs a command and returns the stdout/err output and error if any

func ExecWithEnv

func ExecWithEnv(name string, args []string, env []string, timeout time.Duration, log Log) (Result, error)

ExecWithEnv runs a command with an environment and returns the stdout/err output and error if any

func (Result) CombinedOutput

func (r Result) CombinedOutput() string

CombinedOutput returns Stdout and Stderr as a single string.

Jump to

Keyboard shortcuts

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