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

runframe

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package runframe is the argument parse, environment read and dispatch frame the tools/ci and tools/ghrelease commands share. A tool keeps its own env, its verbs and its banner; the frame holds the one run loop, so a missing verb, a help request, an unknown verb and a verb's own exit code answer the same way in both (the rule: a duplicated function becomes one lower-level module the others depend on; a copy is a bug).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run[E Env, V Verb[E]](e E, args []string, tool, cmd string, banner func() string, names []string, registry map[string]V) int

Run parses args, reads the streams from e and dispatches. No argument prints the banner on stderr and exits 2; "help", "-h" and "--help" print the banner on stdout, or for "help <verb>" that verb's help, and exit 0; an unknown verb is refused as usage on stderr at exit 2; otherwise the verb runs with the arguments after its name and its exit code is returned unchanged. tool names the command in every message, cmd is the line a refusal tells the reader to run, banner renders the help header, and names are the verb names sorted.

Types

type Env

type Env interface {
	Out() io.Writer
	Err() io.Writer
}

Env is what the frame reads from a tool's env: its two streams. A tool's env satisfies it with Out and Err.

type Verb

type Verb[E any] interface {
	// Help is the text `help <name>` prints on stdout.
	Help() string
	// Do runs the verb and returns the process's exit code: 0 done, 1 the
	// thing checked is not so, 2 refused as used (bad usage, or the verb
	// could not run).
	Do(e E, args []string) int
}

Verb is one command a frame dispatches: the help text `help <name>` prints and the function that runs it. E is the tool's own env, so a verb reads the fields its work needs.

Jump to

Keyboard shortcuts

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