executor

package module
v0.1.2-0...-2c856fb Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 12 Imported by: 0

README

executor

Work in progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdOptions

type CmdOptions struct {
	Command string   // Command to run.
	Args    []string // Command arguments.
	Dir     string   // Working directory.
}

CmdOptions respresents options to create a process.

type Command

type Command struct {
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

Command respresents command to launch.

func NewCommand

func NewCommand(ctx context.Context, opts CmdOptions) *Command

NewCommand returns new command with context `ctx` and options `opts`.

func (*Command) PipeAllTo

func (c *Command) PipeAllTo(to *Command)

PipeStderrTo pipes Stdout and Stderr to Stdin of `to`.

func (*Command) PipeStderrTo

func (c *Command) PipeStderrTo(to *Command)

PipeStderrTo pipes Stderr to Stdin of `to`.

func (*Command) PipeStdoutTo

func (c *Command) PipeStdoutTo(to *Command)

PipeStdoutTo pipes Stdout to Stdin of `to`.

func (*Command) SetStdin

func (c *Command) SetStdin(r io.Reader)

SetStdin sets command Stdin to `r`.

func (*Command) Start

func (c *Command) Start(opts StartOptions) (Result, error)

Start starts a process with options `opts`.

type ReadCloser

type ReadCloser struct {
	io.Reader
	io.Closer
}

ReadCloser implements io.ReadCloser.

type Result

type Result struct {
	DoneOk   bool   // Process exited successfully?
	StartOk  bool   // Process started successfully?
	ExitCode int    // Exit code.
	Output   string // Captured output.
}

Result respresents process run result.

type StartOptions

type StartOptions struct {
	ScanStdout bool                          // Scan for Stdout (Capture + Print)?
	ScanStderr bool                          // Scan for Stderr (Capture + Print)?
	Print      bool                          // Print output?
	Capture    bool                          // Build buffer and capture output into Result.Output?
	Wait       bool                          // Wait for program to finish?
	Encoding   *charmap.Charmap              // Endoding.
	NewConsole bool                          // Spawn new console window on Windows?
	Hide       bool                          // Try to hide process window on Windows?
	OnChar     func(c string, p *os.Process) // Callback for each character.
	OnLine     func(l string, p *os.Process) // Callback for each line.
}

StartOptions respresents options to start a process.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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