execbroker

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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.

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