Documentation
¶
Overview ¶
Package command invokes external commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface { SetEnv([]string) SetStdin(io.Reader) SetStdout(io.Writer) SetStderr(io.Writer) StdinPipe() (io.WriteCloser, error) Run() error Start() error Wait() error Output() ([]byte, error) CombinedOutput() ([]byte, error) }
Command contains 2 sets of methods. The first set contains the methods to configure the command to be run (e.g., SetEnv). The second set contains the methods to run the command (e.g., Output). The semantics of the methods conform to that of the counterpart of exec.Cmd.
type Creator ¶
Creator creates a Command. The semantics of the parameters are the same as those of exec.Command.
type ExecCmdCreator ¶
type ExecCmdCreator struct{}
ExecCmdCreator implements CommandCreator by invoking functions offered by os/exec.
func NewExecCmdCreator ¶
func NewExecCmdCreator() *ExecCmdCreator
NewExecCmdCreator creates a new ExecCmdCreator.
type LimaCmdCreator ¶
type LimaCmdCreator interface { // Create creates a new Lima command and connects the stdio of it to the stdio of the current process. Create(args ...string) Command // CreateWithoutStdio creates a new Lima command without connecting the stdio of it to the stdio of the current process. // It is usually used when either Output() or CombinedOutput() instead of Run() needs to be invoked on the returned command. CreateWithoutStdio(args ...string) Command // RunWithReplacingStdout runs a new Lima command, // connects the stdio of it to the stdio of the current process, // and replaces all the strings in stdout according to rs. // // The replacements are executed sequentially. // For example, after executing the first replacement, the resultant stdout will be executed against the second replacement, and so on. // // The reason of directly buffering the string to replace instead of having a customized replacing io.Writer is // that the io.Writer without buffering may fail replacing because one source string can be split to multiple writes. // Implementing an io.Writer with buffering will be more complicated than the current implementation. RunWithReplacingStdout(rs []Replacement, args ...string) error }
LimaCmdCreator creates a limactl command.
func NewLimaCmdCreator ¶
func NewLimaCmdCreator( cmdCreator Creator, logger flog.Logger, limaHomePath, limactlPath string, binPath string, systemDeps LimaCmdCreatorSystemDeps, ) LimaCmdCreator
NewLimaCmdCreator returns a LimaCmdCreator that creates limactl commands based on the provided lima-related paths.
type LimaCmdCreatorSystemDeps ¶
type LimaCmdCreatorSystemDeps interface { system.EnvironGetter system.StdinGetter system.StdoutGetter system.StderrGetter system.EnvGetter }
LimaCmdCreatorSystemDeps contains the system dependencies for NewLimaCmdCreator.
type Replacement ¶
type Replacement struct {
Source, Target string
}
Replacement contains source string to be replaced by target string.