cobrax

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRoot

func BuildRoot(spec RootSpec, reg *resource.Registry, ctx *agentops.AppContext) *cobra.Command

BuildRoot creates a root command with global flags and auto-generated resource commands.

func Execute

func Execute(spec RootSpec, args []string) int

Execute runs the root command and returns a deterministic process exit code.

func ExecuteRoot

func ExecuteRoot(root *cobra.Command, args []string) int

ExecuteRoot runs a pre-built root command with exit code handling.

func GenerateResourceCommands

func GenerateResourceCommands(reg *resource.Registry, root *cobra.Command, ctx *agentops.AppContext)

GenerateResourceCommands walks the registry and creates noun-verb commands. For each resource:

  • Always: create, list, get
  • If Validator: validate
  • If Deleter: remove
  • If Syncer: sync
  • If Transitioner: transition
  • If Doctor: doctor
  • If Pruner: prune

func NewRoot

func NewRoot(spec RootSpec) *cobra.Command

NewRoot builds a root command with standardized persistent flags.

func RenderDoctorChecks added in v0.6.0

func RenderDoctorChecks(w io.Writer, checks []resource.DoctorCheck, jsonMode bool) error

RenderDoctorChecks renders doctor checks as JSON or a table.

func RenderDoctorReport

func RenderDoctorReport(w io.Writer, report agentops.DoctorReport, jsonMode bool) error

RenderDoctorReport renders a DoctorReport as JSON or table.

func RenderPruneResults added in v0.6.0

func RenderPruneResults(w io.Writer, results []resource.PruneResult, jsonMode bool, confirmed bool) error

RenderPruneResults renders prune results as JSON or a table.

func RenderRecords

func RenderRecords(w io.Writer, records []resource.Record, schema resource.ResourceSchema, mode OutputMode, fields []string, jqExpr string) error

RenderRecords renders records based on output mode.

Types

type CommandSpec

type CommandSpec struct {
	Use   string
	Short string
	Run   func(*agentops.AppContext, []string) error
}

CommandSpec describes a subcommand registered under the root command.

type Envelope

type Envelope struct {
	OK       bool             `json:"ok"`
	Kind     string           `json:"kind"`
	Data     []map[string]any `json:"data"`
	Warnings []string         `json:"warnings,omitempty"`
}

Envelope is the JSON output wrapper.

type OutputMode

type OutputMode int

OutputMode for rendering records.

const (
	OutputAuto OutputMode = iota // TTY→table, pipe→TSV
	OutputJSON                   // --json field1,field2
	OutputJQ                     // --jq expression
)

type RootSpec

type RootSpec struct {
	Use      string
	Short    string
	Meta     agentops.AppMeta
	Commands []CommandSpec
}

RootSpec defines the root command contract and shared runtime settings.

Jump to

Keyboard shortcuts

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