command

package
v0.16.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	STDERR_BUFFER_LIMIT = 8 * 1024
	STDERR_BUFFER_GROUP = 512
)
View Source
const (
	NoDir = ""
)

Variables

This section is empty.

Functions

func FromError

func FromError(err error) string

func FromErrorCode

func FromErrorCode(err error) int

func ProcessesCount

func ProcessesCount() int32

ProcessesCount: Get the number of child processes of the default shepherd

Types

type Command

type Command struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, repoPath string, name string, arg ...string) *Command

Create an isolated process based on shepherd

func NewFromOptions

func NewFromOptions(ctx context.Context, opt *RunOpts, name string, arg ...string) *Command

Create an isolated process based on shepherd

func (*Command) Environ

func (c *Command) Environ() []string

func (*Command) Exit

func (c *Command) Exit() error

func (*Command) OneLine

func (c *Command) OneLine() (string, error)

func (*Command) Output

func (c *Command) Output() ([]byte, error)

func (*Command) Run

func (c *Command) Run() error

func (*Command) RunEx

func (c *Command) RunEx() error

func (*Command) Start

func (c *Command) Start() error

func (*Command) StderrPipe

func (c *Command) StderrPipe() (io.ReadCloser, error)

func (*Command) StdinPipe

func (c *Command) StdinPipe() (io.WriteCloser, error)

func (*Command) StdoutPipe

func (c *Command) StdoutPipe() (io.ReadCloser, error)

func (*Command) String

func (c *Command) String() string

func (*Command) UseTime

func (c *Command) UseTime() time.Duration

func (*Command) Wait

func (c *Command) Wait() error

type LimitStderr

type LimitStderr struct {
	*strings.Builder
	// contains filtered or unexported fields
}

func NewStderr

func NewStderr() *LimitStderr

func (*LimitStderr) Bytes

func (w *LimitStderr) Bytes() []byte

func (*LimitStderr) Write

func (w *LimitStderr) Write(p []byte) (int, error)

type RunOpts

type RunOpts struct {
	Environ   []string  // As environ
	ExtraEnv  []string  // append to env
	RepoPath  string    // dir
	Stderr    io.Writer // stderr
	Stdout    io.Writer // stdout
	Stdin     io.Reader // stdin
	Detached  bool      //Detached If true, the child process will not be terminated when the parent process ends
	NoSetpgid bool
}

type Shepherder

type Shepherder interface {
	// NewFromOptions: Create command with options
	NewFromOptions(ctx context.Context, opt *RunOpts, name string, arg ...string) *Command
	// New: Create a process with environment variable isolation
	New(ctx context.Context, repoPath string, name string, arg ...string) *Command
	// ProcessesCount: Get the number of child processes
	ProcessesCount() int32
}

func NewShepherder

func NewShepherder(b env.Builder) Shepherder

Jump to

Keyboard shortcuts

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