Documentation
¶
Index ¶
- func CombinedOut(cmd BaseCmd) (string, error)
- func Out(cmd BaseCmd) (string, error)
- func Run(cmd BaseCmd) error
- func Start(cmd BaseCmd) error
- type BaseCmd
- type Cmd
- func (sh *Cmd) CmdFlags() string
- func (sh Cmd) CombinedOut() (string, error)
- func (sh Cmd) GetExec() *exec.Cmd
- func (sh *Cmd) HideCmd() bool
- func (sh Cmd) Out() (string, error)
- func (sh *Cmd) PSFlags() string
- func (sh *Cmd) RawExec() bool
- func (sh Cmd) Run() error
- func (sh *Cmd) RunWithPS(set bool)
- func (sh Cmd) SetAndCombinedOut(command string) (string, error)
- func (sh Cmd) SetAndCombinedOutf(command string, args ...any) (string, error)
- func (sh Cmd) SetAndOut(command string) (string, error)
- func (sh Cmd) SetAndOutf(command string, args ...any) (string, error)
- func (sh Cmd) SetAndRun(command string) error
- func (sh Cmd) SetAndRunf(command string, args ...any) error
- func (sh Cmd) SetAndStart(command string) error
- func (sh Cmd) SetAndStartf(command string, args ...any) error
- func (sh *Cmd) SetCmdFlags(flags string)
- func (sh *Cmd) SetCmdFlagsf(flags string, args ...any)
- func (sh *Cmd) SetHideCmd(set bool)
- func (sh *Cmd) SetPSFlags(flags string)
- func (sh *Cmd) SetPSFlagsf(flags string, args ...any)
- func (sh *Cmd) SetRawExec(set bool)
- func (sh Cmd) Start() error
- func (sh *Cmd) UsingCmd() bool
- func (sh *Cmd) UsingPS() bool
- type UnixCmd
- type UnixSudoCmd
- type WindowsCmd
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CombinedOut ¶ added in v1.7.0
Execute CombinedOut on all library command types/interfaces.
Types ¶
type BaseCmd ¶ added in v1.7.0
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 ¶ added in v1.7.0
Creates a new BaseCmd interface, which is completely universal and cross-platform.
func NewBaseCmdf ¶ added in v1.7.0
NewBaseCmd but with a fmt.Sprintf in it.
type Cmd ¶
type Cmd struct {
Powershell struct {
PSFlags string
Enabled bool
}
Cmd struct {
CmdFlags string
RawExec bool
HideCmdWindow bool
}
}
func NewCmd ¶ added in v1.7.0
Create a cmd structure convertible to the default interface for your platform. Ex: Windows -> WindowsCmd. Unix -> UnixCmd.
func (Cmd) CombinedOut ¶ added in v1.3.0
Execute the command with all parameters already set, something like "exec.Command([formatted command]).CombinedOutput()" and return its error and string output, as well as executing with output to stdin,stdout and stderr.
func (Cmd) GetExec ¶ added in v1.3.1
Returns the exec.Cmd structure with all parameters already configured.
func (Cmd) Out ¶ added in v1.3.0
Execute the command with all the parameters already set, something like "exec.Command([formatted command]).Output()" and return its string and error output.
func (Cmd) Run ¶ added in v1.3.0
Execute the command with all the parameters already set, something like "exec.Command([formatted command]).Run()" and return its error output.
func (*Cmd) RunWithPS ¶ added in v1.3.0
Run the command using "powershell.exe [parameters] /c command" instead of "cmd.exe [parameters] /c command".
func (Cmd) SetAndCombinedOut ¶ added in v1.3.0
It is the same as cmd := command.Cmd("<command>"); cmd.CombinedOut() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.
func (Cmd) SetAndCombinedOutf ¶ added in v1.6.0
It is the same as a SetAndCombinedOut(fmt.Sprintf(command,args)) but shortened for better handling.
func (Cmd) SetAndOut ¶ added in v1.3.0
It is the same as cmd := command.Cmd("<command>"); cmd.Out() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.
func (Cmd) SetAndOutf ¶ added in v1.6.0
Is the same as a SetAndOut(fmt.Sprintf(command,args)) but shortened for better handling.
func (Cmd) SetAndRun ¶ added in v1.3.0
It is the same as cmd := command.Cmd("<command>"); cmd.Run() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.
func (Cmd) SetAndRunf ¶ added in v1.6.0
Is the same as a SetAndRun(fmt.Sprintf(command,args)) but shortened for better handling.
func (Cmd) SetAndStart ¶ added in v1.3.0
It is the same as cmd := command.Cmd("<command>"); cmd.Start() but in a single argument, what it does is to put an internal input (the one provided) and execute it directly without affecting the main structure.
func (Cmd) SetAndStartf ¶ added in v1.6.0
It is the same as a SetAndStart(fmt.Sprintf(command,args)) but shortened for better handling.
func (*Cmd) SetCmdFlags ¶ added in v1.7.1
It sets the customized cmd flags, its syntax when executed would be something like this "cmd.exe [flags] /c command".
func (*Cmd) SetCmdFlagsf ¶ added in v1.7.1
func (*Cmd) SetHideCmd ¶ added in v1.7.1
Hides the cmd/powershell window that appears when executing a command in go.
func (*Cmd) SetPSFlags ¶ added in v1.7.1
It sets the customized powershell flags, its syntax when executed would be something like this "powershell.exe [flags] /c command".
func (*Cmd) SetPSFlagsf ¶ added in v1.7.1
func (*Cmd) SetRawExec ¶ added in v1.7.1
Execute the command directly, it is useful if you want to execute a binary, this mode does not have access to the path so you will have to put the full path of the binary or use something relative to execute it.
type UnixCmd ¶ added in v1.7.0
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.
type UnixSudoCmd ¶ added in v1.7.0
Unix interface with extra functions to cover sudo execution.
type WindowsCmd ¶ added in v1.7.0
type WindowsCmd interface {
BaseCmd
RunWithPS(bool)
SetRawExec(bool)
RawExec() bool
SetHideCmd(bool)
HideCmd() bool
UsingPS() bool
UsingCmd() bool
SetPSFlags(string)
SetPSFlagsf(string, ...any)
PSFlags() string
SetCmdFlags(string)
SetCmdFlagsf(string, ...any)
CmdFlags() string
}
The exclusive command interface for windows, you can convert BaseCmd -> WindowsCmd with specific functions for that OS.
func NewWindowsCmd ¶ added in v1.7.1
func NewWindowsCmd(command string) WindowsCmd
func NewWindowsCmdf ¶ added in v1.7.1
func NewWindowsCmdf(command string, args ...any) WindowsCmd