cmdrunner

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombinedOutput

func CombinedOutput(command string, args ...string) ([]byte, error)

CombinedOutput calls CombinedOutput on the defined commandRunner, or the default implementation in the exec package if there's no commandRunner defined.

func Command

func Command(cmd string, args ...string) *exec.Cmd

Command calls Command on the defined commandRunner, or the default implementation in the exec package if there's no commandRunner defined.

func CommandContext

func CommandContext(ctx context.Context, cmd string, args ...string) *exec.Cmd

CommandContext calls CommandContext on the defined commandRunner, or the default implementation in the exec package if there's no commandRunner defined.

func GetPrependedCmd

func GetPrependedCmd() string

GetPrependedCmd returns the prepended command if one is configured, else the empty string

func PrependCommandsWith

func PrependCommandsWith(prependCmd string, prependArgs ...string)

PrependCommandsWith updates the commandRunner singleton to have the configured prepended args and command.

func ResetPrependedCmd

func ResetPrependedCmd()

ResetPrependedCmd resets the singleton for more reliable unit testing

Types

type CommandRunner

type CommandRunner interface {
	Command(string, ...string) *exec.Cmd
	CommandContext(context.Context, string, ...string) *exec.Cmd
	CombinedOutput(string, ...string) ([]byte, error)
}

CommandRunner is an interface for executing commands. It gives the option to change the way commands are run server-wide.

Jump to

Keyboard shortcuts

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