shell

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmd string) (exitCode int)

Types

type Command

type Command interface {
	// Starts and wait for completion
	Run() RunError
	// Starts but don't wait for completion. Useful when changing command output to something other than stdout,
	//   using Customize() on builder.
	// `exec.Cmd` is returned to call Wait() on it - but there is no need to call it, if you read the output to
	//   the EOF (in most cases EOF means the process ended)
	Start() (*exec.Cmd, RunError)
}

type CommandBuilder

type CommandBuilder interface {
	Cmd(cmd string, args ...string) Command
	// the higher the confirmation level, the less likely user will be asked to confirm
	ConfirmationLevel(level int) CommandBuilder
}

type RunError

type RunError interface {
	error
	Command() Command
}

type Shell

type Shell interface {
	Cmd(cmd string, args ...string) Command
	CmdBuilder() CommandBuilder
	Run(cmd string, args ...string) RunError
	// show confirmation prompt and wait for user input
	Confirm() error
}

func New

func New() Shell

func NewCustom

func NewCustom(modify func(config *ShellConfig)) Shell

type ShellConfig

type ShellConfig struct {
	PrintCommands     bool
	Simulate          bool
	ConfirmationLevel int
}

Jump to

Keyboard shortcuts

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