Documentation
¶
Overview ¶
Copyright 2023 The Chromium Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultipleCommandsExecutor ¶
type MultipleCommandsExecutor struct {
// contains filtered or unexported fields
}
MultipleCommandsExecutor a executor for executing multiple commands.
Support to execute multiple command like this `ls -a | grep -o | sort -r` This requires `bash` support like this `exec.Command("bash", "-c", "ls -a | grep -o | sort -r")`
This `struct` is created by combining multiple commands by `io.Pipe`. The concept is to pipe the previous command to next command.
func New ¶
func New(cmds ...*exec.Cmd) *MultipleCommandsExecutor
New the function used for creating an `MultipleCommandsExecutor`
For example: `ls -a | grep -o | sort -r` multipleCmdsExecutor := New(
exec.Command("ls", "-a"), exec.Command("grep", "-o"), exec.Command("sort", "-r"),
)
func (*MultipleCommandsExecutor) Exec ¶
func (c *MultipleCommandsExecutor) Exec(executor executor.IExecCommander) ([]byte, error)
Exec start executing the commands and waiting for the result. We will close all the `io.PipeWriter` after finished.