util

package
v0.0.0-...-da7d6d0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package util provide different utilities that are used by rocker TODO: this should be refactored to a different packages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecPipe

func ExecPipe(cmd *Cmd) (string, int, error)

ExecPipe executes the command and returns its output, exit code and error

func MakeAbsolute

func MakeAbsolute(path string) (result string, err error)

MakeAbsolute makes any path absolute, either according to a HOME or from a working directory

func PrefixPipe

func PrefixPipe(prefix string, writer io.Writer) io.Writer

PrefixPipe creates an io wrapper that will add [prefix] to every line written

func ResolvePath

func ResolvePath(baseDir, subPath string) (resultPath string, err error)

ResolvePath resolves the subPath from baseDir such that the resultig path cannot go outside the baseDir

Types

type Cmd

type Cmd struct {
	Args       []string
	Env        []string
	Dir        string
	Stream     io.Writer
	Reader     *io.PipeReader
	Writer     *io.PipeWriter
	ExitStatus int
	Error      error
}

Cmd is a wrapper over os/exec and provides extra convenience stuff

func Exec

func Exec(cmd *Cmd) (*Cmd, error)

Exec runs the command and grabs exit code at the end If Stream property is present, then it also pipes stdout/stderr to it

func (*Cmd) Pipe

func (cmd *Cmd) Pipe(writer io.Writer) error

Pipe pipes cmd stdout/stderr to a given io.Writer

func (*Cmd) String

func (cmd *Cmd) String() string

String returns debug representation of the Cmd

Jump to

Keyboard shortcuts

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