app

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package app holds shared CLI runtime concerns: the injected environment and instant/zone parsing used across commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseInstant

func ParseInstant(value string, loc *time.Location) (time.Time, error)

ParseInstant parses an instant in the given zone, trying each accepted layout.

func ParseZone

func ParseZone(name string) (*time.Location, error)

ParseZone resolves an IANA zone name, defaulting to the local zone.

func RealSleep

func RealSleep(ctx context.Context, d time.Duration) error

RealSleep waits with a timer honoring context cancellation.

func RealSpawn

func RealSpawn(ctx context.Context, name string, args []string) error

RealSpawn runs a command, wiring its stdio to the process, honoring context.

Types

type Clock

type Clock func() time.Time

Clock supplies the current instant; injected so commands are testable.

type Env

type Env struct {
	Now   Clock
	Out   io.Writer
	Err   io.Writer
	Sleep Sleeper
	Spawn Spawner
	Zone  *time.Location
}

Env is the injected runtime for every command: clock, output streams, and the wait/spawn effects. Tests supply fakes; main wires the real ones.

type Sleeper

type Sleeper func(ctx context.Context, d time.Duration) error

Sleeper waits for d or until ctx is cancelled, returning ctx.Err() on cancel.

type Spawner

type Spawner func(ctx context.Context, name string, args []string) error

Spawner runs an external command; injected so `run` is testable.

Jump to

Keyboard shortcuts

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