cmd

package
v0.0.0-...-f4b31ea Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package cmd provides support for running commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

type CommandRunner interface {
	RunCommand(ctx context.Context, stdoutBuf, stderrBuf io.Writer, dir, name string, args ...string) error
}

CommandRunner is the common interface for this module.

type FakeCommandRunner

type FakeCommandRunner struct {
	// Stdout and Stderr will be written to the buffers passed into RunCommand.
	Stdout string
	Stderr string
	// Only one of ExpectedCmd and ExpectedCmdPartial can be set.
	// If ExpectedCmd is set, then that should be exactly the command's name and args, or RunCommand will return an error.
	ExpectedCmd []string
	// If ExpectedCmdPartial is set, then that should be a segment of the command's name and args, in order, or RunCommand will return an error.
	ExpectedCmdPartial []string
	// If ExpectedDir is set, then it should be exactly the dir passed into RunCommand.
	ExpectedDir string
	// If FailCommand is True, then RunCommand will raise FailError.
	FailCommand bool
	FailError   error
}

FakeCommandRunner does not actually run commands. It is used for testing.

func (FakeCommandRunner) RunCommand

func (c FakeCommandRunner) RunCommand(ctx context.Context, stdoutBuf, stderrBuf io.Writer, dir, name string, args ...string) error

RunCommand runs a command (not actually).

type FakeCommandRunnerMulti

type FakeCommandRunnerMulti struct {
	CommandRunners []FakeCommandRunner
	// contains filtered or unexported fields
}

FakeCommandRunnerMulti provides multiple command runners. Each command is expected to be run in the given order.

func (*FakeCommandRunnerMulti) RunCommand

func (c *FakeCommandRunnerMulti) RunCommand(ctx context.Context, stdoutBuf, stderrBuf io.Writer, dir, name string, args ...string) error

RunCommand runs a command (not actually).

type RealCommandRunner

type RealCommandRunner struct{}

RealCommandRunner actually runs commands.

func (RealCommandRunner) RunCommand

func (c RealCommandRunner) RunCommand(ctx context.Context, stdoutBuf, stderrBuf io.Writer, dir, name string, args ...string) error

RunCommand runs a command.

Jump to

Keyboard shortcuts

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