command

package
v1.37.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandContext

type CommandContext interface {
	// Env returns the environment variables set for the CommandContext
	Env() []string
	// Dir returns the directory set for the CommandContext
	Dir() string
	// Stdin returns the stdin set for the CommandContext
	Stdin() io.Reader

	// Run runs a given command and will append any extra paths to the configured directory
	Run(cmd *exec.Cmd, path ...string) ([]byte, error)
}

CommandContext represents the context that commands are run in

type GenericCommandContext

type GenericCommandContext struct {
	// contains filtered or unexported fields
}

GenericCommandContext is a generic implementation of the CommandContext interface

func NewGenericCommandContext

func NewGenericCommandContext(opts ...GenericCommandContextOptions) *GenericCommandContext

NewGenericCommandContext creates a new GenericCommandContext that can be configured via GenericCommandContextOptions functions

func (*GenericCommandContext) Dir

func (gcc *GenericCommandContext) Dir() string

Dir returns the directory set for the GenericCommandContext

func (*GenericCommandContext) Env

func (gcc *GenericCommandContext) Env() []string

Env returns the environment variables set for the GenericCommandContext

func (*GenericCommandContext) Run

func (gcc *GenericCommandContext) Run(cmd *exec.Cmd, path ...string) ([]byte, error)

Run runs a given command and will append any extra paths to the configured directory

func (*GenericCommandContext) Stdin

func (gcc *GenericCommandContext) Stdin() io.Reader

Stdin returns the stdin set for the GenericCommandContext

type GenericCommandContextOptions

type GenericCommandContextOptions func(gcc *GenericCommandContext)

GenericCommandContextOptions is a function used to configure a GenericCommandContext

func WithDir

WithDir sets the directory that commands should be run in

func WithEnv

func WithEnv(env ...string) GenericCommandContextOptions

WithEnv sets the environment variables that should be used when running commands

func WithStdin

func WithStdin(stdin io.Reader) GenericCommandContextOptions

WithStdin sets the stdin when running commands

Jump to

Keyboard shortcuts

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