process

package
v0.0.0-...-8d0dba2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MaxOutputLineBytes = 4 << 20

Variables

This section is empty.

Functions

func CommandContext

func CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd

CommandContext binds cancellation to the whole command tree. Build tools and task commands can spawn children that otherwise retain pipes after the parent exits.

func NowRFC3339Nano

func NowRFC3339Nano() string

Types

type CommandSpec

type CommandSpec struct {
	Name        string
	Args        []string
	Dir         string
	Env         map[string]string
	LogPath     string
	AppendLog   bool
	OnLine      func(stream, line string)
	Grace       time.Duration
	ReadyWait   time.Duration
	Interactive bool
	// Terminal gives a prompting child its own terminal; output streams are merged.
	Terminal    bool
	Prompts     []PromptSpec
	OnPrompt    func(PromptRequest) (PromptResponse, error)
	ParsePrompt PromptParser

	// GracefulStop replaces the initial termination signal with a protocol-specific
	// shutdown request. It must honor its context; request and exit share Grace.
	// Failure or expiry still escalates to an OS process-tree kill.
	GracefulStop func(context.Context) error
}

type Handle

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

func Start

func Start(ctx context.Context, spec CommandSpec) (*Handle, error)

func (*Handle) Alive

func (h *Handle) Alive() bool

func (*Handle) PID

func (h *Handle) PID() int

func (*Handle) Stop

func (h *Handle) Stop() error

func (*Handle) Wait

func (h *Handle) Wait() error

func (*Handle) WriteString

func (h *Handle) WriteString(value string) error

type PromptKind

type PromptKind string
const (
	PromptConfirm PromptKind = "confirm"
	PromptText    PromptKind = "text"
	PromptSelect  PromptKind = "select"
)

type PromptMatch

type PromptMatch struct {
	Request PromptRequest
	Input   func(PromptResponse) (string, error)
}

PromptMatch describes a rendered question and translates an explicit answer into the child's input protocol. Input returns exact bytes, without an added newline.

type PromptParser

type PromptParser func(string) *PromptMatch

PromptParser recognizes tool-specific questions in bounded, settled output. It must return nil for incomplete output and completed prompt redraws.

type PromptRequest

type PromptRequest struct {
	Prompt  string
	Kind    PromptKind
	Secret  bool
	Choices []string
}

type PromptResponse

type PromptResponse struct {
	Value string
}

type PromptSpec

type PromptSpec struct {
	Pattern  string
	Patterns []string
	Prompt   string
	Kind     PromptKind
	Repeat   bool
	Secret   bool
}

type Result

type Result struct {
	ExitCode int
}

func Run

func Run(ctx context.Context, spec CommandSpec) (Result, error)

Jump to

Keyboard shortcuts

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