io

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunCmd

func RunCmd(config CmdConfig) error

Runs an external process and prints its output to stdout / stderr.

func RunCmdOutput

func RunCmdOutput(config CmdConfig) (string, error)

Executes an external process and returns its output. If the returned output is not needed, use the RunCmd function instead , for better performance.

func RunCmdWithOutputParser

func RunCmdWithOutputParser(config CmdConfig, prompt bool, regExpStruct ...*CmdOutputPattern) (stdOut string, errorOut string, exitOk bool, err error)

Executes the command and captures the output. Analyze each line to match the provided regex. Returns the complete stdout output of the command.

Types

type CmdConfig

type CmdConfig interface {
	GetCmd() *exec.Cmd
	GetEnv() map[string]string
	GetStdWriter() io.WriteCloser
	GetErrWriter() io.WriteCloser
}

type CmdOutputPattern

type CmdOutputPattern struct {
	RegExp         *regexp.Regexp
	MatchedResults [][]string
	Line           string
	ExecFunc       func(pattern *CmdOutputPattern) (string, error)
}

RegExp - The regexp that the line will be searched upon. MatchedResults - The slice result that was found by the regex Line - The output line from the external process ExecFunc - The function to execute

Jump to

Keyboard shortcuts

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