execute

package module
v0.0.0-...-ebef9c2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 8 Imported by: 0

README

go-execute

  • Upgraded go version to 1.22
  • Added SysAttr support

Credits: alexellis

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecResult

type ExecResult struct {
	Stdout    string
	Stderr    string
	ExitCode  int
	Cancelled bool
}

type ExecTask

type ExecTask struct {
	// Command is the command to execute. This can be the path to an executable
	// or the executable with arguments. The arguments are detected by looking for
	// a space.
	//
	// Any arguments must be given via Args
	Command string

	// Args are the arguments to pass to the command. These are ignored if the
	// Command contains arguments.
	Args []string

	// Shell run the command in a bash shell.
	// Note that the system must have `bash` installed in the PATH or in /bin/bash
	Shell bool

	// Env is a list of environment variables to add to the current environment,
	// these are used to override any existing environment variables.
	Env []string

	// Cwd is the working directory for the command
	Cwd string

	// Stdin connect a reader to stdin for the command
	// being executed.
	Stdin io.Reader

	// PrintCommand prints the command before executing
	PrintCommand bool

	// StreamStdio prints stdout and stderr directly to os.Stdout/err as
	// the command runs.
	StreamStdio bool

	// DisableStdioBuffer prevents any output from being saved in the
	// TaskResult, which is useful for when the result is very large, or
	// when you want to stream the output to another writer exclusively.
	DisableStdioBuffer bool

	// StdoutWriter when set will receive a copy of stdout from the command
	StdOutWriter io.Writer

	// StderrWriter when set will receive a copy of stderr from the command
	StdErrWriter io.Writer

	// SysProcAttr holds optional, operating system-specific attributes.
	// These attributes can be used to control various aspects of the process
	// execution, such as setting the process group ID, controlling the
	// creation of a new session, setting resource limits, and more.
	SysProcAttr *syscall.SysProcAttr
}

func (ExecTask) Execute

func (et ExecTask) Execute(ctx context.Context) (ExecResult, error)

Jump to

Keyboard shortcuts

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