Documentation
¶
Overview ¶
Package cli exposes the fixed Mulgae command registry and its dispatcher.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateCommandSpecs ¶
func ValidateCommandSpecs(specs []CommandSpec) error
ValidateCommandSpecs rejects a registry that is incomplete or whose command metadata differs from the canonical Mulgae contract.
Types ¶
type CommandSpec ¶
type CommandSpec struct {
// contains filtered or unexported fields
}
CommandSpec is immutable metadata for one command in the fixed Mulgae surface.
func CommandSpecs ¶
func CommandSpecs() []CommandSpec
CommandSpecs returns a fresh copy of the canonical, ordered 19-command registry.
func (CommandSpec) Command ¶
func (spec CommandSpec) Command() app.CommandName
Command returns the command named by this specification.
func (CommandSpec) OutputContractURIs ¶
func (spec CommandSpec) OutputContractURIs() []string
OutputContractURIs returns a caller-owned copy of the command's output contracts.
func (CommandSpec) Owner ¶
func (spec CommandSpec) Owner() string
Owner returns the application package that owns the command.
func (CommandSpec) RequestContractURI ¶
func (spec CommandSpec) RequestContractURI() string
RequestContractURI returns the command's literal request-variant URI.
func (CommandSpec) Service ¶
func (spec CommandSpec) Service() string
Service returns the application service that implements the command.
func (CommandSpec) TypedExits ¶
func (spec CommandSpec) TypedExits() []app.ExitCode
TypedExits returns a caller-owned copy of the command's assigned failure exits.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher routes commands from a validated registry.
func NewDispatcher ¶
func NewDispatcher(specs []CommandSpec, handlers map[app.CommandName]Handler) (*Dispatcher, error)
NewDispatcher validates a complete canonical registry and handler set before constructing an immutable dispatcher.
func (*Dispatcher) Dispatch ¶
func (dispatcher *Dispatcher) Dispatch(ctx context.Context, command app.CommandName, args []string) (app.CommandResult, error)
Dispatch executes a command. Callers must parse raw command tokens with app.ParseCommandName before dispatching them. Registry and handler invariants are returned as Go errors.
type EnvelopeRenderer ¶
type EnvelopeRenderer struct {
// contains filtered or unexported fields
}
EnvelopeRenderer renders application command results as the common command result contract. It is immutable after construction.
func NewEnvelopeRenderer ¶
func NewEnvelopeRenderer(clock ports.Clock, validator SchemaValidator) (*EnvelopeRenderer, error)
NewEnvelopeRenderer constructs a renderer with the required wall clock and final-envelope schema validator.
func (*EnvelopeRenderer) Render ¶
func (renderer *EnvelopeRenderer) Render(ctx context.Context, commandResult app.CommandResult, requestRaw, failureResultRaw []byte) ([]byte, error)
Render returns a schema-validated canonical command-result envelope followed by exactly one newline. requestRaw and selected result data must each contain exactly one non-null JSON object with no duplicate keys. Failed command results use failureResultRaw because the command contract requires a result object even when command execution failed.