runtime

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package runtime is the dependency boundary between the binary shell in cmd/jira and the command implementations. It carries the IO streams a command invocation needs that are otherwise process-global: stdout, stderr, and stdin.

Runtime is constructed once per process by main (and once per test by the internal/cli/root test helper). It is deliberately small: it owns inputs, not behavior. It does NOT store a context.Context — main owns the root context via signal.NotifyContext and threads it through ExecuteContext. Runtime never calls os.Exit and exposes no broad service-locator surface; command-domain logic lives in the command packages.

TTY detection is derived from the stdout stream (an *os.File in production) rather than carried as a separate field — see runtimeStdoutIsTTY in internal/cli/root. Environment, config-path, timeout, clock, and request-ID inputs are intentionally absent: their consumers are not yet wired through the runtime, and an option that does not reach its consumer is a correctness trap. They return to this boundary when each one is wired to its consumer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Runtime) error

Option configures a Runtime during construction. An Option returns an error to reject invalid input (e.g. a nil writer).

func WithStderr

func WithStderr(w io.Writer) Option

WithStderr sets the writer commands render diagnostics to.

func WithStdin

func WithStdin(r io.Reader) Option

WithStdin sets the reader commands consume piped input from.

func WithStdout

func WithStdout(w io.Writer) Option

WithStdout sets the writer commands render successful output to. A nil writer is rejected so a misconfigured runtime fails fast at New rather than panicking mid-command.

type Runtime

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

Runtime holds the per-invocation IO streams shared across the command tree. All fields have safe defaults applied by New; callers override them with Option values.

func New

func New(options ...Option) (*Runtime, error)

New builds a Runtime, applying defaults first and then each Option in order. Defaults wire the process streams so a zero-Option call yields a production-ready runtime.

func (*Runtime) Stderr

func (rt *Runtime) Stderr() io.Writer

Stderr returns the writer commands render diagnostics to.

func (*Runtime) Stdin

func (rt *Runtime) Stdin() io.Reader

Stdin returns the reader commands consume piped input from.

func (*Runtime) Stdout

func (rt *Runtime) Stdout() io.Writer

Stdout returns the writer commands render successful output to.

Jump to

Keyboard shortcuts

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