command

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name           string
	EnvPassthrough bool
	ExecOpts       []ExecOpt
}

Command is a functional options wrapper around exec.Cmd.

func NewCommand

func NewCommand(name string, opts ...Opt) *Command

NewCommand creates a new command.

func (*Command) Cmd

func (c *Command) Cmd(ctx context.Context) *exec.Cmd

Cmd takes a context and returns an instance of *exec.Cmd.

func (*Command) Run

func (c *Command) Run(ctx context.Context) (*exec.Cmd, error)

Run takes a context.Context and executes itself. It returns an instance of *exec.Cmd and an error.

type ExecOpt

type ExecOpt func(*exec.Cmd)

ExecOpt is a functional options wrapper around *exec.Cmd. These options are applied to the Cmd instance before it is run.

type Opt

type Opt func(*Command)

Opt is a functional options wrapper around Command.

func WithArgs

func WithArgs(args ...string) Opt

WithArgs sets the command arguments.

func WithDir

func WithDir(dir string) Opt

WithDir sets the command directory.

func WithEnv

func WithEnv(vars map[string]string) Opt

WithEnv sets the command environment variables.

func WithEnvPassthrough

func WithEnvPassthrough() Opt

WithEnvPassthrough passes the current process environment to the command.

func WithUI

func WithUI(ui *terminal.UI) Opt

WithUI takes a UI and configures the cmd's STDERR, STDIN, and STDOUT to use the UI's outputs.

Jump to

Keyboard shortcuts

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