cli

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 9 Imported by: 0

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.

type Handler

type Handler interface {
	Execute(context.Context, []string) (app.CommandResult, error)
}

Handler executes one command.

type SchemaValidator

type SchemaValidator interface {
	Validate(context.Context, ports.AssetID, []byte) error
}

SchemaValidator validates raw JSON against a catalog schema. It is satisfied by adapters/jsonschema.Validator without coupling this CLI adapter to it.

Jump to

Keyboard shortcuts

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