command

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombinedOut

func CombinedOut(cmd BaseCmd) (string, error)

Execute CombinedOut on all library command types/interfaces.

func Out

func Out(cmd BaseCmd) (string, error)

Execute Out on all library command types/interfaces.

func Run

func Run(cmd BaseCmd) error

Execute Run on all library command types/interfaces.

func Start

func Start(cmd BaseCmd) error

Execute Start on all library command types/interfaces.

Types

type BaseCmd

type BaseCmd interface {
	GetExec() *exec.Cmd

	SetInput(string)
	SetInputf(string, ...any)

	Std(bool, bool, bool)
	Stdout(bool)
	Stdin(bool)
	Stderr(bool)

	Run() error
	Out() (string, error)
	Start() error
	CombinedOut() (string, error)

	SetAndStartf(string, ...any) error
	SetAndCombinedOutf(string, ...any) (string, error)
	SetAndOutf(string, ...any) (string, error)
	SetAndRunf(string, ...any) error

	SetAndStart(string) error
	SetAndCombinedOut(string) (string, error)
	SetAndOut(string) (string, error)
	SetAndRun(string) error
}

The universal base interface for the others, can be converted unidirectionally to all others.

func NewBaseCmd

func NewBaseCmd(command string) BaseCmd

Creates a new BaseCmd interface, which is completely universal and cross-platform.

func NewBaseCmdf

func NewBaseCmdf(command string, args ...any) BaseCmd

NewBaseCmd but with a fmt.Sprintf in it.

type UnixCmd

type UnixCmd interface {
	BaseCmd

	RunWithShell(bool)
	UseBashShell(bool)
	CustomShell(string, string)
	GetChroot() (string, bool)
	SetChroot(string)
	SetChrootf(string, ...any)
	EnableChroot()
	DisableChroot()
}

An exclusive interface for unix, which has the specific functions for that OS.

func NewUnixCmd

func NewUnixCmd(command string) UnixCmd

Creates a UnixCmd interface that is convertible to: UnixCmd -> UnixSudoCmd.

func NewUnixCmdf

func NewUnixCmdf(command string, args ...any) UnixCmd

NewUnixCmd but with a fmt.Sprintf in it.

type UnixSudoCmd

type UnixSudoCmd interface {
	UnixCmd

	SetPasswd(string)
}

Unix interface with extra functions to cover sudo execution.

func NewUnixSudoCmd

func NewUnixSudoCmd(command string, optionalPassword ...string) UnixSudoCmd

Creates a UnixCmd interface but with specific functions for executing sudo commands.

func NewUnixSudoCmdf

func NewUnixSudoCmdf(passwd, command string, args ...any) UnixSudoCmd

NewUnixSudoCmd but with a fmt.Sprintf in it.

type WindowsCmd

type WindowsCmd interface {
	BaseCmd

	RunWithPS(bool)
	RunWithoutCmd(bool)
	HideCmdWindow(bool)

	CustomPSFlags(string)
	CustomPSFlagsf(string, ...any)

	CustomCmdFlags(string)
	CustomCmdFlagsf(string, ...any)
}

The exclusive command interface for windows, you can convert BaseCmd -> WindowsCmd with specific functions for that OS.

Jump to

Keyboard shortcuts

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