commander

package
v0.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 5 Imported by: 0

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