commander

package
v0.1.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReal

func NewReal() types.Commander

NewReal creates a real commander

Types

type Mock

type Mock struct {
	Commands      map[string]bool   // which commands exist
	Responses     map[string]string // command pattern -> output
	Errors        map[string]error  // command pattern -> error
	RecordedCalls []RecordedCall    // all calls made
}

Mock implements Commander for testing

func NewMock

func NewMock() *Mock

NewMock creates a mock commander

func (*Mock) LookPath

func (m *Mock) LookPath(name string) (string, error)

LookPath checks if a command exists in the mock

func (*Mock) Run

func (m *Mock) Run(ctx context.Context, name string, args []string, dir string) (string, error)

Run records the call and returns mocked response

type Real

type Real struct{}

Real implements Commander using actual system commands

func (*Real) LookPath

func (r *Real) LookPath(name string) (string, error)

LookPath checks if a command exists

func (*Real) Run

func (r *Real) Run(ctx context.Context, name string, args []string, dir string) (string, error)

Run executes a command

type RecordedCall

type RecordedCall struct {
	Name string
	Args []string
	Dir  string
}

RecordedCall captures a command invocation

Jump to

Keyboard shortcuts

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