command

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 4 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	ExecUseShell execShellFlag = true
	ExecNoShell  execShellFlag = false
)
View Source
const (
	ExecIgnoreErrors   execIgnoreErrorsFlag = true
	ExecNoIgnoreErrors execIgnoreErrorsFlag = false
)
View Source
const (
	ExecQuiet   execQuietFlag = true
	ExecNoQuiet execQuietFlag = false
)

Variables

This section is empty.

Functions

func Exec

func Exec(parameters ...any) gloo.Command[[]byte, []byte]

Exec returns a Command that runs an external program as a pipeline stage: the input stream is written to the program's stdin and its stdout becomes the output stream (exactly the role of a command in a shell pipe).

The program and its arguments are the positional string parameters:

Exec("tr", "a-z", "A-Z")

Flags (see opt.go and the alias package):

  • ExecWorkingDir(dir): run in dir
  • ExecEnvVar("K=V"): add an environment variable (repeatable)
  • ExecShell(sh) / ExecUseShell: run the command line through a shell
  • ExecQuiet: discard the program's stderr
  • ExecIgnoreErrors: succeed even if the program exits non-zero

When no flag needs shell features the program is executed directly; otherwise it is run through a POSIX shell so the flags can take effect.

Note: a generic exec runs arbitrary binaries, which the framework otherwise discourages in favor of per-tool Subprocess wrappers. It is offered here as an explicit, opt-in escape hatch.

func Plan

func Plan(parameters ...any) (name string, args []string, err error)

Plan resolves parameters into the concrete program and arguments Exec would run, without spawning anything. It is the dry-run / preview counterpart of Exec: a caller can log or inspect the exact command line first. It returns ErrNoCommand when no program is named.

When no flag needs shell features the program and its arguments are returned directly; otherwise the program is wrapped in a POSIX shell invocation ("sh -c <command line>") so the flags take effect.

Types

type Error

type Error string

Error is the sentinel error type for this package. Every error the package can emit is a constant of this type, so callers match with errors.Is.

const ErrNoCommand Error = "exec: no command specified"

ErrNoCommand is returned by Exec when no program is given to run.

func (Error) Error

func (e Error) Error() string

Error renders the sentinel's message.

type ExecEnvVar

type ExecEnvVar string

ExecEnvVar adds one KEY=VALUE environment variable (repeatable).

type ExecShell

type ExecShell string

ExecShell names the shell interpreter to route the command through.

type ExecWorkingDir

type ExecWorkingDir string

ExecWorkingDir runs the command in the named directory.

Directories

Path Synopsis
Package alias provides unprefixed type aliases for exec command flags.
Package alias provides unprefixed type aliases for exec command flags.

Jump to

Keyboard shortcuts

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