runner

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package runner provides utilities to execute commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

type Default struct {
	Quiet bool
}

Default is the Runner that executes the command by default.

func (*Default) CmdCombinedOutput

func (d *Default) CmdCombinedOutput(cmd *exec.Cmd) ([]byte, error)

CmdCombinedOutput executes the command and returns the command stdout and stderr.

func (*Default) CmdOutput

func (d *Default) CmdOutput(cmd *exec.Cmd) ([]byte, error)

CmdOutput executes the command and returns the command stdout.

func (*Default) CmdRun

func (d *Default) CmdRun(cmd *exec.Cmd) error

CmdRun executes the command.

type Dry

type Dry struct{}

Dry is the Runner that only prints commands and does not execute them.

func (*Dry) CmdCombinedOutput

func (d *Dry) CmdCombinedOutput(cmd *exec.Cmd) ([]byte, error)

CmdCombinedOutput prints the command.

func (*Dry) CmdOutput

func (d *Dry) CmdOutput(cmd *exec.Cmd) ([]byte, error)

CmdOutput prints the command.

func (*Dry) CmdRun

func (*Dry) CmdRun(cmd *exec.Cmd) error

CmdRun prints the command.

type Multi added in v0.6.0

type Multi struct {
	Quiet bool
}

Multi will both print the output for the user and return it to callers. Useful for debugging, e.g. if the importer calls terraform import but it freezes without returning output. Inspired by https://blog.kowalczyk.info/article/wOYk/advanced-command-execution-in-go-with-osexec.html

func (*Multi) CmdCombinedOutput added in v0.6.0

func (d *Multi) CmdCombinedOutput(cmd *exec.Cmd) ([]byte, error)

CmdCombinedOutput executes the command and prints stdout and stderr then returns them.

func (*Multi) CmdOutput added in v0.6.0

func (d *Multi) CmdOutput(cmd *exec.Cmd) ([]byte, error)

CmdOutput executes the command and prints stdout and stderr then returns just stdout.

func (*Multi) CmdRun added in v0.6.0

func (d *Multi) CmdRun(cmd *exec.Cmd) error

CmdRun executes the command and prints stdout and stderr without returning either.

type Runner

type Runner interface {
	CmdRun(cmd *exec.Cmd) error
	CmdOutput(cmd *exec.Cmd) ([]byte, error)
	CmdCombinedOutput(cmd *exec.Cmd) ([]byte, error)
}

Runner is the interface to execute commands.

Jump to

Keyboard shortcuts

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