Documentation
¶
Index ¶
- Variables
- func AddArgs(args ...string) option.Func[*exec.Cmd]
- func AddEnv(key, value string) option.Func[*exec.Cmd]
- func AddExtraFiles(extraFiles ...*os.File) option.Func[*exec.Cmd]
- func AddStderrs(stderrs ...io.Writer) option.Func[*exec.Cmd]
- func AddStdins(stdins ...io.Reader) option.Func[*exec.Cmd]
- func AddStdouts(stdouts ...io.Writer) option.Func[*exec.Cmd]
- func New(ctx context.Context, name string, options ...option.Option[*exec.Cmd]) (*exec.Cmd, error)
- func Output(ctx context.Context, name string, options ...option.Option[*exec.Cmd]) (*bytes.Buffer, *bytes.Buffer, *exec.Cmd, error)
- func Run(ctx context.Context, name string, options ...option.Option[*exec.Cmd]) (*exec.Cmd, error)
- func SetArgs(args ...string) option.Func[*exec.Cmd]
- func SetDir(dir string) option.Func[*exec.Cmd]
- func SetEnv(env ...string) option.Func[*exec.Cmd]
- func SetExtraFiles(extraFiles ...*os.File) option.Func[*exec.Cmd]
- func SetStderr(stderr io.Writer) option.Func[*exec.Cmd]
- func SetStdin(stdin io.Reader) option.Func[*exec.Cmd]
- func SetStdout(stdout io.Writer) option.Func[*exec.Cmd]
- func SetSysProcAttr(attr *syscall.SysProcAttr) option.Func[*exec.Cmd]
- func SetWaitDelay(delay time.Duration) option.Func[*exec.Cmd]
- func Start(ctx context.Context, name string, options ...option.Option[*exec.Cmd]) (*exec.Cmd, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCommandBuild = errors.New("error building command")
ErrCommandBuild is the error returned when building a command.
Functions ¶
func AddExtraFiles ¶
AddExtraFiles adds extra files to the command.
func AddStderrs ¶
AddStderrs adds standard errors to the command.
func AddStdouts ¶
AddStdouts adds standard outputs to the command.
func Run ¶
Run runs the command and returns the combined output.
Example ¶
package main
import (
"context"
"os"
"github.com/broothie/cob"
)
func main() {
cob.Run(context.TODO(), "echo",
cob.AddArgs("Hello,"),
cob.AddArgs("World"),
cob.AddEnv("SHELL", "bash"),
cob.SetStdin(os.Stdin),
cob.SetStdout(os.Stdout),
)
}
Output: Hello, World
func SetExtraFiles ¶
SetExtraFiles sets the extra files for the command.
func SetSysProcAttr ¶
SetSysProcAttr sets the system process attributes for the command.
func SetWaitDelay ¶
SetWaitDelay sets the wait delay for the command.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.