Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cli is hmm's command line: flag parsing, stdin handling, the turn pump, session persistence, and exit codes. Presentation is not here — Run wires the streams into one ui.Console and every line of output goes through it; main only wires the real OS streams and signals.

Index

Constants

View Source
const Version = "0.1.0"

Version is reported by --version.

Variables

This section is empty.

Functions

func IsTTY

func IsTTY(f *os.File) bool

IsTTY reports whether f is a real terminal. The ModeCharDevice stat check alone counts /dev/null as a TTY (it is a character device), which made non-interactive runs print the model picker into nothing; the TCGETS ioctl asks the device itself. Linux only; other platforms build the stat-check fallback in tty_other.go.

func Run

func Run(ctx context.Context, argv []string, io IO) int

Run executes one hmm invocation and returns its exit code.

Types

type IO

type IO struct {
	Stdin       io.Reader
	StdinIsTTY  bool
	Stdout      io.Writer
	Stderr      io.Writer
	StdoutIsTTY bool // markdown-rendered answers (glamour) on a TTY
	StderrIsTTY bool // spinner + colored activity feed on a TTY

	// NewModel resolves the provider config into a model. Default:
	// agent.NewModel. Tests substitute wefttest.Script.
	NewModel func(agent.Config) (weft.Model, error)
	// Store persists sessions. Default: session.New() ($HMM_HOME
	// aware). A nil Store with SessionDir set is a test store.
	Store      *session.Store
	SessionDir string
	// Library mounts the plugin library. Default: plugins.New()
	// ($HMM_HOME aware), scanned at startup.
	Library *plugins.Library
	Now     func() time.Time
}

IO carries everything Run touches, so tests inject scripts, buffers, and a fake store. Zero NewModel/Store/Now fall back to the real things.

Jump to

Keyboard shortcuts

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