cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownCommand = errors.New("unknown command")

ErrUnknownCommand is returned by Run for a verb that is not registered or carries no handler. The dispatcher must fail closed on it (exit 2), never 0.

View Source
var ErrUsage = errors.New("usage")

ErrUsage is the sentinel for fail-closed rejections that must map to exit code 2 (usage / out-of-phase / invalid-enum), as opposed to gate/verify failures which exit 1. main.go inspects it. Wrap it, never return it bare, so the message names the specific violation (spec 03 R2, R3).

View Source
var Registry map[string]Handler

Registry is populated in init() rather than as a var initializer: the runMCP handler now reaches Run (via the injected MCP executor), and Run reads Registry — a static var-initializer graph would flag that as an initialization cycle. init() assignment is exempt from that analysis and still runs before any dispatch.

Functions

func RegisteredCommandNames added in v0.3.0

func RegisteredCommandNames() []string

func Run added in v0.3.0

func Run(root, name string, args []string, flags map[string]string) error

Run is the single dispatch choke point. It resolves the verb, enforces declared flag enums and lifecycle-phase compatibility *before* any handler side effect, then invokes the handler. Fail-closed rejections wrap ErrUsage (exit 2); unknown verbs wrap ErrUnknownCommand (exit 2). This is the one place the harness turns command metadata into enforcement (spec 03).

func RunAuthorized added in v0.4.0

func RunAuthorized(root, name string, args []string, flags map[string]string, authority core.AuthorityV1, changedPaths []string, now time.Time) error

RunAuthorized enforces a mission authority packet before normal dispatch.

Types

type Handler added in v0.3.0

type Handler func(root string, args []string, flags map[string]string) error

Jump to

Keyboard shortcuts

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