exe

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package exe enables template completion before command execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(s string, obj interface{}, settings ...SettingsFunc) *exec.Cmd

Execute runs the function on the default Runner.

func ExecuteE

func ExecuteE(s string, obj interface{}, settings ...SettingsFunc) (*exec.Cmd, error)

ExecuteE runs the function on the default Runner.

func ExecuteEWithContext

func ExecuteEWithContext(ctx context.Context, s string, obj interface{}, settings ...SettingsFunc) (*exec.Cmd, error)

ExecuteE runs the function on the default Runner.

func ExecuteWithContext

func ExecuteWithContext(ctx context.Context, s string, obj interface{}, settings ...SettingsFunc) *exec.Cmd

Execute runs the function on the default Runner.

func ExecuteWithOutput

func ExecuteWithOutput(s string, obj interface{}, settings ...SettingsFunc) string

ExecuteWithOutput runs the function on the default Runner.

func ExecuteWithOutputE

func ExecuteWithOutputE(s string, obj interface{}, settings ...SettingsFunc) (out string, err error)

ExecuteWithOutputE runs the command on the default runner.

func Run

func Run(cmd *exec.Cmd, name string, settings ...SettingsFunc)

Run runs the function on the default Runner.

func RunE

func RunE(cmd *exec.Cmd, name string, settings ...SettingsFunc) (err error)

RunE runs the function on the default Runner.

func RunWithOutput

func RunWithOutput(cmd *exec.Cmd, name string, settings ...SettingsFunc) string

RunWithOutput runs the function on the default Runner.

func RunWithOutputE

func RunWithOutputE(cmd *exec.Cmd, name string, settings ...SettingsFunc) (out string, err error)

RunWithOutputE runs the function on the default Runner.

func SplitCommand

func SplitCommand(s string) []string

SplitCommand runs the function on the default Runner.

func WithStart

func WithStart(s *ExecuteSetting)

WithStart sets the command to run async.

Types

type ExecuteSetting

type ExecuteSetting struct {
	// contains filtered or unexported fields
}

ExecuteSetting holds options to apply to a command runner.

type Runner

type Runner interface {
	Run(cmd *exec.Cmd, name string, settings ...SettingsFunc)
	RunE(cmd *exec.Cmd, name string, settings ...SettingsFunc) (err error)

	RunWithOutput(cmd *exec.Cmd, name string, settings ...SettingsFunc) string
	RunWithOutputE(cmd *exec.Cmd, name string, settings ...SettingsFunc) (out string, err error)

	Execute(s string, obj interface{}, settings ...SettingsFunc) *exec.Cmd
	ExecuteE(s string, obj interface{}, settings ...SettingsFunc) (*exec.Cmd, error)

	SplitCommand(string) []string

	ExecuteWithContext(ctx context.Context, s string, obj interface{}, settings ...SettingsFunc) *exec.Cmd
	ExecuteEWithContext(ctx context.Context, s string, obj interface{}, settings ...SettingsFunc) (*exec.Cmd, error)

	ExecuteWithOutput(s string, obj interface{}, settings ...SettingsFunc) string
	ExecuteWithOutputE(s string, obj interface{}, settings ...SettingsFunc) (out string, err error)
}

Runner combines all run functions into one interface.

func DefaultRunner

func DefaultRunner() Runner

DefaultRunner returns the default Runner implementation.

type SettingsFunc

type SettingsFunc func(s *ExecuteSetting)

SettingsFunc is a function which modifies the execution setting.

func WithDir

func WithDir(path string) SettingsFunc

WithDir sets working directory to use when running the command.

func WithTimeout

func WithTimeout(duration time.Duration) SettingsFunc

WithTimeout sets a maximum duration to wait.

Jump to

Keyboard shortcuts

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