execbroker

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clearenv added in v0.3.2

func Clearenv()

Clearenv removes all variables from the active command scope. Without a scope, it has the same behavior as os.Clearenv.

func Command

func Command(name string, args ...string) *exec.Cmd

Command is the brokered equivalent of exec.Command.

func CommandContext

func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd

CommandContext is the brokered equivalent of exec.CommandContext.

func Do

func Do(scope Scope, fn func() error) error

Do runs fn with the supplied command scope.

func Environ added in v0.3.2

func Environ() []string

Environ returns a copy of the active command scope environment. Without a scope, it has the same behavior as os.Environ.

func ExpandEnv added in v0.3.2

func ExpandEnv(s string) string

ExpandEnv expands variables using the active command scope environment.

func Getenv added in v0.3.2

func Getenv(key string) string

Getenv returns the value of key from the active command scope. Without a scope, it has the same behavior as os.Getenv.

func LookupEnv added in v0.3.2

func LookupEnv(key string) (string, bool)

LookupEnv returns the value of key and whether it is present in the active command scope. Without a scope, it has the same behavior as os.LookupEnv.

func Println

func Println(a ...any) (int, error)

Println writes to the stdout configured for the active scope.

func Run

func Run(cmd *exec.Cmd) error

Run applies the active scope to an existing command and runs it. This is used by runtimes such as gsh that construct exec.Cmd internally.

func Setenv added in v0.3.2

func Setenv(key, value string) error

Setenv sets key in the active command scope. The first scoped write copies the process environment so later commands inherit the update without changing the process-wide environment. Without a scope, it has the same behavior as os.Setenv.

func Unsetenv added in v0.3.2

func Unsetenv(key string) error

Unsetenv removes key from the active command scope. Without a scope, it has the same behavior as os.Unsetenv.

Types

type Middleware

type Middleware func(Request) (Request, error)

Middleware may rewrite a command before execution. Returning an error prevents the command from starting.

type Request

type Request struct {
	Name   string
	Args   []string
	Env    []string
	Dir    string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

Request describes a command before it is turned into an exec.Cmd.

type Scope

type Scope struct {
	Env        []string
	Dir        string
	Stdin      io.Reader
	Stdout     io.Writer
	Stderr     io.Writer
	Middleware Middleware
}

Scope supplies process-independent defaults for commands created while fn runs. Custom fields already set on a command take precedence.

Jump to

Keyboard shortcuts

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