executil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package executil contains some common wrappers for simple use of exec.Cmd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombinedOutput

func CombinedOutput(c *exec.Cmd) (string, error)

CombinedOutput runs a command and returns the output string of c.CombinedOutput.

func Dir

func Dir(dir, name string, args ...string) *exec.Cmd

Dir returns a command that runs in the given dir. The command can be passed to one of the other funcs in this package to evaluate it and optionally get the output as a string. Dir is useful to construct one-liner command calls, because setting the dir is commonly needed and not settable with exec.Command directly.

func MakeWorkDir

func MakeWorkDir(rootDir string) (string, error)

MakeWorkDir creates a unique path inside the given root dir to use as a workspace. The name starts with the local time in a sortable format to help with browsing multiple workspaces. This function allows a command to run multiple times in sequence without overwriting or deleting the old data, for diagnostic purposes. This function uses os.MkdirAll to ensure the root dir exists.

func Run

func Run(c *exec.Cmd) error

Run sets up the command to log directly to our stdout/stderr streams, then runs it.

func RunQuiet

func RunQuiet(c *exec.Cmd) error

RunQuiet logs the command line and runs the given command, but sends the output to os.DevNull.

func SpaceTrimmedCombinedOutput

func SpaceTrimmedCombinedOutput(c *exec.Cmd) (string, error)

SpaceTrimmedCombinedOutput runs CombinedOutput and trims leading/trailing spaces from the result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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