Documentation
¶
Overview ¶
Package osexec provides simple and flexible command execution utilities
osexec 提供简单而灵活的命令执行工具包
Provides enhanced abstraction on os/exec with customizable configurations 提供增强的 os/exec 抽象接口,支持可定制的配置选项
Supports custom environment variables, working paths, and shell options 支持自定义环境变量、工作路径和 shell 选项
Includes debug modes and intelligent error handling capabilities 包含调试模式和智能错误处理能力
Index ¶
- func Exec(name string, args ...string) ([]byte, error)
- func ExecInEnvs(envs []string, name string, args ...string) ([]byte, error)
- func ExecInPath(path string, name string, args ...string) ([]byte, error)
- func ExecXshRun(shellType, shellFlag string, name string, args ...string) ([]byte, error)
- func GetDebugMode() bool
- func SetDebugMode(enable bool)
- type CommandConfig
- func (c *CommandConfig) Exec(name string, args ...string) ([]byte, error)
- func (c *CommandConfig) ExecInPipe(name string, args ...string) ([]byte, error)
- func (c *CommandConfig) ExecTake(name string, args ...string) ([]byte, int, error)
- func (c *CommandConfig) ExecWith(name string, args []string, prepare func(command *exec.Cmd)) ([]byte, error)
- func (c *CommandConfig) IsShowCommand() bool
- func (c *CommandConfig) IsShowOutputs() bool
- func (c *CommandConfig) Must() *CommandConfig88Must
- func (c *CommandConfig) NewConfig() *CommandConfig
- func (c *CommandConfig) Omit() *CommandConfig88Omit
- func (c *CommandConfig) Soft() *CommandConfig88Soft
- func (c *CommandConfig) StreamExec(name string, args ...string) ([]byte, error)
- func (c *CommandConfig) SubConfig(path string) *CommandConfig
- func (c *CommandConfig) WithBash() *CommandConfig
- func (c *CommandConfig) WithDebug() *CommandConfig
- func (c *CommandConfig) WithDebugMode(debugMode DebugMode) *CommandConfig
- func (c *CommandConfig) WithEnvs(envs []string) *CommandConfig
- func (c *CommandConfig) WithExpectCode(exitCode int) *CommandConfig
- func (c *CommandConfig) WithExpectExit(exitCode int, reason string) *CommandConfig
- func (c *CommandConfig) WithMatchMore(matchMore bool) *CommandConfig
- func (c *CommandConfig) WithMatchPipe(matchPipe func(outputLine string) bool) *CommandConfig
- func (c *CommandConfig) WithPath(path string) *CommandConfig
- func (c *CommandConfig) WithSh() *CommandConfig
- func (c *CommandConfig) WithShell(shellType, shellFlag string) *CommandConfig
- func (c *CommandConfig) WithShellFlag(shellFlag string) *CommandConfig
- func (c *CommandConfig) WithShellType(shellType string) *CommandConfig
- func (c *CommandConfig) WithTakeExits(takeExits map[int]string) *CommandConfig
- func (c *CommandConfig) WithZsh() *CommandConfig
- type CommandConfig88Must
- func (T *CommandConfig88Must) Exec(name string, args ...string) (res []byte)
- func (T *CommandConfig88Must) ExecInPipe(name string, args ...string) (res []byte)
- func (T *CommandConfig88Must) ExecTake(name string, args ...string) (res []byte, res1 int)
- func (T *CommandConfig88Must) ExecWith(name string, args []string, prepare func(command *exec.Cmd)) (res []byte)
- func (T *CommandConfig88Must) IsShowCommand() (res bool)
- func (T *CommandConfig88Must) IsShowOutputs() (res bool)
- func (T *CommandConfig88Must) NewConfig() (res *CommandConfig)
- func (T *CommandConfig88Must) StreamExec(name string, args ...string) (res []byte)
- func (T *CommandConfig88Must) SubConfig(path string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithBash() (res *CommandConfig)
- func (T *CommandConfig88Must) WithDebug() (res *CommandConfig)
- func (T *CommandConfig88Must) WithDebugMode(debugMode DebugMode) (res *CommandConfig)
- func (T *CommandConfig88Must) WithEnvs(envs []string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithExpectCode(exitCode int) (res *CommandConfig)
- func (T *CommandConfig88Must) WithExpectExit(exitCode int, reason string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithMatchMore(matchMore bool) (res *CommandConfig)
- func (T *CommandConfig88Must) WithMatchPipe(matchPipe func(outputLine string) bool) (res *CommandConfig)
- func (T *CommandConfig88Must) WithPath(path string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithSh() (res *CommandConfig)
- func (T *CommandConfig88Must) WithShell(shellType string, shellFlag string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithShellFlag(shellFlag string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithShellType(shellType string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithTakeExits(takeExits map[int]string) (res *CommandConfig)
- func (T *CommandConfig88Must) WithZsh() (res *CommandConfig)
- type CommandConfig88Omit
- func (T *CommandConfig88Omit) Exec(name string, args ...string) (res []byte)
- func (T *CommandConfig88Omit) ExecInPipe(name string, args ...string) (res []byte)
- func (T *CommandConfig88Omit) ExecTake(name string, args ...string) (res []byte, res1 int)
- func (T *CommandConfig88Omit) ExecWith(name string, args []string, prepare func(command *exec.Cmd)) (res []byte)
- func (T *CommandConfig88Omit) IsShowCommand() (res bool)
- func (T *CommandConfig88Omit) IsShowOutputs() (res bool)
- func (T *CommandConfig88Omit) NewConfig() (res *CommandConfig)
- func (T *CommandConfig88Omit) StreamExec(name string, args ...string) (res []byte)
- func (T *CommandConfig88Omit) SubConfig(path string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithBash() (res *CommandConfig)
- func (T *CommandConfig88Omit) WithDebug() (res *CommandConfig)
- func (T *CommandConfig88Omit) WithDebugMode(debugMode DebugMode) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithEnvs(envs []string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithExpectCode(exitCode int) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithExpectExit(exitCode int, reason string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithMatchMore(matchMore bool) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithMatchPipe(matchPipe func(outputLine string) bool) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithPath(path string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithSh() (res *CommandConfig)
- func (T *CommandConfig88Omit) WithShell(shellType string, shellFlag string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithShellFlag(shellFlag string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithShellType(shellType string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithTakeExits(takeExits map[int]string) (res *CommandConfig)
- func (T *CommandConfig88Omit) WithZsh() (res *CommandConfig)
- type CommandConfig88Soft
- func (T *CommandConfig88Soft) Exec(name string, args ...string) (res []byte)
- func (T *CommandConfig88Soft) ExecInPipe(name string, args ...string) (res []byte)
- func (T *CommandConfig88Soft) ExecTake(name string, args ...string) (res []byte, res1 int)
- func (T *CommandConfig88Soft) ExecWith(name string, args []string, prepare func(command *exec.Cmd)) (res []byte)
- func (T *CommandConfig88Soft) IsShowCommand() (res bool)
- func (T *CommandConfig88Soft) IsShowOutputs() (res bool)
- func (T *CommandConfig88Soft) NewConfig() (res *CommandConfig)
- func (T *CommandConfig88Soft) StreamExec(name string, args ...string) (res []byte)
- func (T *CommandConfig88Soft) SubConfig(path string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithBash() (res *CommandConfig)
- func (T *CommandConfig88Soft) WithDebug() (res *CommandConfig)
- func (T *CommandConfig88Soft) WithDebugMode(debugMode DebugMode) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithEnvs(envs []string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithExpectCode(exitCode int) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithExpectExit(exitCode int, reason string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithMatchMore(matchMore bool) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithMatchPipe(matchPipe func(outputLine string) bool) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithPath(path string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithSh() (res *CommandConfig)
- func (T *CommandConfig88Soft) WithShell(shellType string, shellFlag string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithShellFlag(shellFlag string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithShellType(shellType string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithTakeExits(takeExits map[int]string) (res *CommandConfig)
- func (T *CommandConfig88Soft) WithZsh() (res *CommandConfig)
- type DebugMode
- type ExecConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecInEnvs ¶
ExecInEnvs executes a command with custom environment variables. ExecInEnvs 使用自定义环境变量执行一个命令。
func ExecInPath ¶
ExecInPath executes a command in a specified DIR. ExecInPath 在指定的 DIR 中执行一个命令。
func ExecXshRun ¶
ExecXshRun executes a command using a specific shell type and shell flag. ExecXshRun 使用指定的 shell 类型和 shell 标志执行一个命令。
func GetDebugMode ¶
func GetDebugMode() bool
GetDebugMode returns the package-wide debug mode status GetDebugMode 返回包级别的调试模式状态
func SetDebugMode ¶
func SetDebugMode(enable bool)
SetDebugMode sets the package-wide debug mode SetDebugMode 设置包级别的调试模式
Types ¶
type CommandConfig ¶
type CommandConfig struct {
Envs []string // Custom environment variables // 自定义环境变量
Path string // Execution path // 执行路径
ShellType string // Type of shell to use, e.g., bash, zsh // shell 类型,例如 bash,zsh
ShellFlag string // Shell flag, e.g., "-c" // Shell 参数,例如 "-c"
DebugMode DebugMode // Debug mode setting // 调试模式设置
MatchPipe func(outputLine string) bool // Function to match output lines in pipe mode // 管道模式下匹配输出行的函数
MatchMore bool // Continue matching even when matched // 即使匹配成功也继续匹配
TakeExits map[int]string // Map of expected exit codes with reasons // 预期退出码及其原因的映射表
}
CommandConfig represents the configuration when executing shell commands CommandConfig 表示执行 shell 命令时的配置
func NewCommandConfig ¶
func NewCommandConfig() *CommandConfig
NewCommandConfig creates and returns a new CommandConfig instance. NewCommandConfig 创建并返回一个新的 CommandConfig 实例。
func (*CommandConfig) Exec ¶
func (c *CommandConfig) Exec(name string, args ...string) ([]byte, error)
Exec executes a shell command with the specified name and arguments, using the CommandConfig configuration. Exec 使用 CommandConfig 的配置执行带有指定名称和参数的 shell 命令。
func (*CommandConfig) ExecInPipe ¶
func (c *CommandConfig) ExecInPipe(name string, args ...string) ([]byte, error)
ExecInPipe executes a shell command with the specified name and arguments, using the CommandConfig configuration, and returns the output as a byte slice. ExecInPipe 使用 CommandConfig 的配置执行带有指定名称和参数的 shell 命令,并返回输出的字节切片。
func (*CommandConfig) ExecTake ¶
ExecTake executes a command and returns output, exit code, and an issue if one exists Returns exit code enabling fine-grained handling of command outcomes Exit code 0 indicates success, non-zero indicates various conditions
ExecTake 执行命令并返回输出、退出码和错误(如果有的话) 返回退出码以便精细处理命令结果 退出码 0 表示成功,非零表示各种情况
func (*CommandConfig) ExecWith ¶
func (c *CommandConfig) ExecWith(name string, args []string, prepare func(command *exec.Cmd)) ([]byte, error)
ExecWith executes a command with custom exec.Cmd preparation Allows setting stdin, extra env vars, and additional cmd fields via prepare callback
ExecWith 执行命令,支持自定义 exec.Cmd 配置 通过 prepare 回调可设置 stdin、额外环境变量和其它 cmd 字段
func (*CommandConfig) IsShowCommand ¶
func (c *CommandConfig) IsShowCommand() bool
IsShowCommand checks if the command should be displayed based on the debug mode IsShowCommand 检查是否应根据调试模式显示命令
func (*CommandConfig) IsShowOutputs ¶
func (c *CommandConfig) IsShowOutputs() bool
IsShowOutputs checks if the command results should be displayed based on the debug mode IsShowOutputs 检查是否应根据调试模式显示命令结果
func (*CommandConfig) Must ¶
func (c *CommandConfig) Must() *CommandConfig88Must
func (*CommandConfig) NewConfig ¶
func (c *CommandConfig) NewConfig() *CommandConfig
NewConfig creates a shallow clone of the CommandConfig instance. NewConfig 克隆一个新的 CommandConfig 实例,以便于实现总配置和子配置分隔.
func (*CommandConfig) Omit ¶
func (c *CommandConfig) Omit() *CommandConfig88Omit
func (*CommandConfig) Soft ¶
func (c *CommandConfig) Soft() *CommandConfig88Soft
func (*CommandConfig) StreamExec ¶
func (c *CommandConfig) StreamExec(name string, args ...string) ([]byte, error)
StreamExec executes a shell command with the specified name and arguments, using the CommandConfig configuration, and returns the output as a byte slice. StreamExec 使用 CommandConfig 的配置执行带有指定名称和参数的 shell 命令,并返回输出的字节切片。
func (*CommandConfig) SubConfig ¶
func (c *CommandConfig) SubConfig(path string) *CommandConfig
SubConfig creates a shallow clone of the CommandConfig instance with a new path and returns the updated instance. SubConfig 创建一个带有新路径的 CommandConfig 实例的浅克隆并返回更新后的实例。
func (*CommandConfig) WithBash ¶
func (c *CommandConfig) WithBash() *CommandConfig
WithBash sets the shell to bash with the "-c" flag and returns the updated instance. WithBash 设置 shell 为 bash 并附带 "-c" 参数,返回更新后的实例。
func (*CommandConfig) WithDebug ¶
func (c *CommandConfig) WithDebug() *CommandConfig
WithDebug sets the debug mode to true and returns the updated instance WithDebug 将调试模式设置 true 并返回更新后的实例
func (*CommandConfig) WithDebugMode ¶
func (c *CommandConfig) WithDebugMode(debugMode DebugMode) *CommandConfig
WithDebugMode sets the debug mode and returns the updated instance WithDebugMode 设置调试模式并返回更新后的实例
func (*CommandConfig) WithEnvs ¶
func (c *CommandConfig) WithEnvs(envs []string) *CommandConfig
WithEnvs sets the environment variables and returns the updated instance WithEnvs 设置环境变量并返回更新后的实例
func (*CommandConfig) WithExpectCode ¶
func (c *CommandConfig) WithExpectCode(exitCode int) *CommandConfig
WithExpectCode adds an expected exit code and returns the updated instance WithExpectCode 添加期望的退出码并返回更新后的实例
func (*CommandConfig) WithExpectExit ¶
func (c *CommandConfig) WithExpectExit(exitCode int, reason string) *CommandConfig
WithExpectExit adds an expected exit code and returns the updated instance WithExpectExit 添加期望的退出码并返回更新后的实例
func (*CommandConfig) WithMatchMore ¶
func (c *CommandConfig) WithMatchMore(matchMore bool) *CommandConfig
WithMatchMore sets the match more flag and returns the updated instance WithMatchMore 设置匹配更多标志并返回更新后的实例
func (*CommandConfig) WithMatchPipe ¶
func (c *CommandConfig) WithMatchPipe(matchPipe func(outputLine string) bool) *CommandConfig
WithMatchPipe sets the match pipe function and returns the updated instance WithMatchPipe 设置匹配管道函数并返回更新后的实例
func (*CommandConfig) WithPath ¶
func (c *CommandConfig) WithPath(path string) *CommandConfig
WithPath sets the execution path and returns the updated instance WithPath 设置执行路径并返回更新后的实例
func (*CommandConfig) WithSh ¶
func (c *CommandConfig) WithSh() *CommandConfig
WithSh sets the shell to sh with the "-c" flag and returns the updated instance. WithSh 设置 shell 为 sh 并附带 "-c" 参数,返回更新后的实例。
func (*CommandConfig) WithShell ¶
func (c *CommandConfig) WithShell(shellType, shellFlag string) *CommandConfig
WithShell sets both the shell type and shell flag, returns the updated instance WithShell 同时设置 shell 类型和 shell 参数,返回更新后的实例
func (*CommandConfig) WithShellFlag ¶
func (c *CommandConfig) WithShellFlag(shellFlag string) *CommandConfig
WithShellFlag sets the shell flag and returns the updated instance WithShellFlag 设置 shell 参数并返回更新后的实例
func (*CommandConfig) WithShellType ¶
func (c *CommandConfig) WithShellType(shellType string) *CommandConfig
WithShellType sets the shell type and returns the updated instance WithShellType 设置 shell 类型并返回更新后的实例
func (*CommandConfig) WithTakeExits ¶
func (c *CommandConfig) WithTakeExits(takeExits map[int]string) *CommandConfig
WithTakeExits sets the accepted exit codes and returns the updated instance WithTakeExits 设置接受退出码集合并返回更新后的实例
func (*CommandConfig) WithZsh ¶
func (c *CommandConfig) WithZsh() *CommandConfig
WithZsh sets the shell to zsh with the "-c" flag and returns the updated instance. WithZsh 设置 shell 为 zsh 并附带 "-c" 参数,返回更新后的实例。
type CommandConfig88Must ¶
type CommandConfig88Must struct {
// contains filtered or unexported fields
}
func (*CommandConfig88Must) Exec ¶
func (T *CommandConfig88Must) Exec(name string, args ...string) (res []byte)
func (*CommandConfig88Must) ExecInPipe ¶
func (T *CommandConfig88Must) ExecInPipe(name string, args ...string) (res []byte)
func (*CommandConfig88Must) ExecTake ¶
func (T *CommandConfig88Must) ExecTake(name string, args ...string) (res []byte, res1 int)
func (*CommandConfig88Must) IsShowCommand ¶
func (T *CommandConfig88Must) IsShowCommand() (res bool)
func (*CommandConfig88Must) IsShowOutputs ¶
func (T *CommandConfig88Must) IsShowOutputs() (res bool)
func (*CommandConfig88Must) NewConfig ¶
func (T *CommandConfig88Must) NewConfig() (res *CommandConfig)
func (*CommandConfig88Must) StreamExec ¶
func (T *CommandConfig88Must) StreamExec(name string, args ...string) (res []byte)
func (*CommandConfig88Must) SubConfig ¶
func (T *CommandConfig88Must) SubConfig(path string) (res *CommandConfig)
func (*CommandConfig88Must) WithBash ¶
func (T *CommandConfig88Must) WithBash() (res *CommandConfig)
func (*CommandConfig88Must) WithDebug ¶
func (T *CommandConfig88Must) WithDebug() (res *CommandConfig)
func (*CommandConfig88Must) WithDebugMode ¶
func (T *CommandConfig88Must) WithDebugMode(debugMode DebugMode) (res *CommandConfig)
func (*CommandConfig88Must) WithEnvs ¶
func (T *CommandConfig88Must) WithEnvs(envs []string) (res *CommandConfig)
func (*CommandConfig88Must) WithExpectCode ¶
func (T *CommandConfig88Must) WithExpectCode(exitCode int) (res *CommandConfig)
func (*CommandConfig88Must) WithExpectExit ¶
func (T *CommandConfig88Must) WithExpectExit(exitCode int, reason string) (res *CommandConfig)
func (*CommandConfig88Must) WithMatchMore ¶
func (T *CommandConfig88Must) WithMatchMore(matchMore bool) (res *CommandConfig)
func (*CommandConfig88Must) WithMatchPipe ¶
func (T *CommandConfig88Must) WithMatchPipe(matchPipe func(outputLine string) bool) (res *CommandConfig)
func (*CommandConfig88Must) WithPath ¶
func (T *CommandConfig88Must) WithPath(path string) (res *CommandConfig)
func (*CommandConfig88Must) WithSh ¶
func (T *CommandConfig88Must) WithSh() (res *CommandConfig)
func (*CommandConfig88Must) WithShell ¶
func (T *CommandConfig88Must) WithShell(shellType string, shellFlag string) (res *CommandConfig)
func (*CommandConfig88Must) WithShellFlag ¶
func (T *CommandConfig88Must) WithShellFlag(shellFlag string) (res *CommandConfig)
func (*CommandConfig88Must) WithShellType ¶
func (T *CommandConfig88Must) WithShellType(shellType string) (res *CommandConfig)
func (*CommandConfig88Must) WithTakeExits ¶
func (T *CommandConfig88Must) WithTakeExits(takeExits map[int]string) (res *CommandConfig)
func (*CommandConfig88Must) WithZsh ¶
func (T *CommandConfig88Must) WithZsh() (res *CommandConfig)
type CommandConfig88Omit ¶
type CommandConfig88Omit struct {
// contains filtered or unexported fields
}
func (*CommandConfig88Omit) Exec ¶
func (T *CommandConfig88Omit) Exec(name string, args ...string) (res []byte)
func (*CommandConfig88Omit) ExecInPipe ¶
func (T *CommandConfig88Omit) ExecInPipe(name string, args ...string) (res []byte)
func (*CommandConfig88Omit) ExecTake ¶
func (T *CommandConfig88Omit) ExecTake(name string, args ...string) (res []byte, res1 int)
func (*CommandConfig88Omit) IsShowCommand ¶
func (T *CommandConfig88Omit) IsShowCommand() (res bool)
func (*CommandConfig88Omit) IsShowOutputs ¶
func (T *CommandConfig88Omit) IsShowOutputs() (res bool)
func (*CommandConfig88Omit) NewConfig ¶
func (T *CommandConfig88Omit) NewConfig() (res *CommandConfig)
func (*CommandConfig88Omit) StreamExec ¶
func (T *CommandConfig88Omit) StreamExec(name string, args ...string) (res []byte)
func (*CommandConfig88Omit) SubConfig ¶
func (T *CommandConfig88Omit) SubConfig(path string) (res *CommandConfig)
func (*CommandConfig88Omit) WithBash ¶
func (T *CommandConfig88Omit) WithBash() (res *CommandConfig)
func (*CommandConfig88Omit) WithDebug ¶
func (T *CommandConfig88Omit) WithDebug() (res *CommandConfig)
func (*CommandConfig88Omit) WithDebugMode ¶
func (T *CommandConfig88Omit) WithDebugMode(debugMode DebugMode) (res *CommandConfig)
func (*CommandConfig88Omit) WithEnvs ¶
func (T *CommandConfig88Omit) WithEnvs(envs []string) (res *CommandConfig)
func (*CommandConfig88Omit) WithExpectCode ¶
func (T *CommandConfig88Omit) WithExpectCode(exitCode int) (res *CommandConfig)
func (*CommandConfig88Omit) WithExpectExit ¶
func (T *CommandConfig88Omit) WithExpectExit(exitCode int, reason string) (res *CommandConfig)
func (*CommandConfig88Omit) WithMatchMore ¶
func (T *CommandConfig88Omit) WithMatchMore(matchMore bool) (res *CommandConfig)
func (*CommandConfig88Omit) WithMatchPipe ¶
func (T *CommandConfig88Omit) WithMatchPipe(matchPipe func(outputLine string) bool) (res *CommandConfig)
func (*CommandConfig88Omit) WithPath ¶
func (T *CommandConfig88Omit) WithPath(path string) (res *CommandConfig)
func (*CommandConfig88Omit) WithSh ¶
func (T *CommandConfig88Omit) WithSh() (res *CommandConfig)
func (*CommandConfig88Omit) WithShell ¶
func (T *CommandConfig88Omit) WithShell(shellType string, shellFlag string) (res *CommandConfig)
func (*CommandConfig88Omit) WithShellFlag ¶
func (T *CommandConfig88Omit) WithShellFlag(shellFlag string) (res *CommandConfig)
func (*CommandConfig88Omit) WithShellType ¶
func (T *CommandConfig88Omit) WithShellType(shellType string) (res *CommandConfig)
func (*CommandConfig88Omit) WithTakeExits ¶
func (T *CommandConfig88Omit) WithTakeExits(takeExits map[int]string) (res *CommandConfig)
func (*CommandConfig88Omit) WithZsh ¶
func (T *CommandConfig88Omit) WithZsh() (res *CommandConfig)
type CommandConfig88Soft ¶
type CommandConfig88Soft struct {
// contains filtered or unexported fields
}
func (*CommandConfig88Soft) Exec ¶
func (T *CommandConfig88Soft) Exec(name string, args ...string) (res []byte)
func (*CommandConfig88Soft) ExecInPipe ¶
func (T *CommandConfig88Soft) ExecInPipe(name string, args ...string) (res []byte)
func (*CommandConfig88Soft) ExecTake ¶
func (T *CommandConfig88Soft) ExecTake(name string, args ...string) (res []byte, res1 int)
func (*CommandConfig88Soft) IsShowCommand ¶
func (T *CommandConfig88Soft) IsShowCommand() (res bool)
func (*CommandConfig88Soft) IsShowOutputs ¶
func (T *CommandConfig88Soft) IsShowOutputs() (res bool)
func (*CommandConfig88Soft) NewConfig ¶
func (T *CommandConfig88Soft) NewConfig() (res *CommandConfig)
func (*CommandConfig88Soft) StreamExec ¶
func (T *CommandConfig88Soft) StreamExec(name string, args ...string) (res []byte)
func (*CommandConfig88Soft) SubConfig ¶
func (T *CommandConfig88Soft) SubConfig(path string) (res *CommandConfig)
func (*CommandConfig88Soft) WithBash ¶
func (T *CommandConfig88Soft) WithBash() (res *CommandConfig)
func (*CommandConfig88Soft) WithDebug ¶
func (T *CommandConfig88Soft) WithDebug() (res *CommandConfig)
func (*CommandConfig88Soft) WithDebugMode ¶
func (T *CommandConfig88Soft) WithDebugMode(debugMode DebugMode) (res *CommandConfig)
func (*CommandConfig88Soft) WithEnvs ¶
func (T *CommandConfig88Soft) WithEnvs(envs []string) (res *CommandConfig)
func (*CommandConfig88Soft) WithExpectCode ¶
func (T *CommandConfig88Soft) WithExpectCode(exitCode int) (res *CommandConfig)
func (*CommandConfig88Soft) WithExpectExit ¶
func (T *CommandConfig88Soft) WithExpectExit(exitCode int, reason string) (res *CommandConfig)
func (*CommandConfig88Soft) WithMatchMore ¶
func (T *CommandConfig88Soft) WithMatchMore(matchMore bool) (res *CommandConfig)
func (*CommandConfig88Soft) WithMatchPipe ¶
func (T *CommandConfig88Soft) WithMatchPipe(matchPipe func(outputLine string) bool) (res *CommandConfig)
func (*CommandConfig88Soft) WithPath ¶
func (T *CommandConfig88Soft) WithPath(path string) (res *CommandConfig)
func (*CommandConfig88Soft) WithSh ¶
func (T *CommandConfig88Soft) WithSh() (res *CommandConfig)
func (*CommandConfig88Soft) WithShell ¶
func (T *CommandConfig88Soft) WithShell(shellType string, shellFlag string) (res *CommandConfig)
func (*CommandConfig88Soft) WithShellFlag ¶
func (T *CommandConfig88Soft) WithShellFlag(shellFlag string) (res *CommandConfig)
func (*CommandConfig88Soft) WithShellType ¶
func (T *CommandConfig88Soft) WithShellType(shellType string) (res *CommandConfig)
func (*CommandConfig88Soft) WithTakeExits ¶
func (T *CommandConfig88Soft) WithTakeExits(takeExits map[int]string) (res *CommandConfig)
func (*CommandConfig88Soft) WithZsh ¶
func (T *CommandConfig88Soft) WithZsh() (res *CommandConfig)
type DebugMode ¶
type DebugMode string
DebugMode represents the debug output setting when executing commands DebugMode 表示执行命令时的调试输出设置
const ( QUIET DebugMode = "QUIET" // Quiet mode with no debug output // 静默模式,无任何调试输出 DEBUG DebugMode = "DEBUG" // Complete debug mode with detailed information // 完整调试模式,包含所有调试信息 SHOW_COMMAND DebugMode = "SHOW_COMMAND" // Show command, not outputs // 显示命令,不显示输出 SHOW_OUTPUTS DebugMode = "SHOW_OUTPUTS" // Show outputs, not command // 显示输出,不显示命令 )
func NewDebugMode ¶
NewDebugMode creates a DebugMode based on the debug mode flag. When debugModeOpen is true, returns DEBUG; otherwise, returns QUIET. NewDebugMode 根据调试模式标志创建 DebugMode。当 debugModeOpen 为 true 时,返回 DEBUG;否则返回 QUIET。
type ExecConfig ¶
type ExecConfig = CommandConfig
ExecConfig is an alias representing CommandConfig ExecConfig 是 CommandConfig 的别名
func NewExecConfig ¶
func NewExecConfig() *ExecConfig
NewExecConfig creates and returns a new ExecConfig instance NewExecConfig 创建并返回新的 ExecConfig 实例
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
demos/demo1x
command
|
|
|
demos/demo2x
command
|
|
|
utils
Package utils provides utilities supporting command execution and output formatting
|
Package utils provides utilities supporting command execution and output formatting |
|
Package osexectest provides testing utilities for command execution tests Contains functions to skip tests when commands are not available in PATH Logs command paths when commands are found on the system
|
Package osexectest provides testing utilities for command execution tests Contains functions to skip tests when commands are not available in PATH Logs command paths when commands are found on the system |