cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeclined = errors.New("declined")

ErrDeclined marks a user-declined confirmation: a normal outcome that must exit 0 without touching the API.

Functions

func Execute

func Execute() error

Execute runs the root command. Errors returned by subcommands are printed by cobra; the exit code is decided here so subcommands can signal specific codes.

Types

type EntityDef

type EntityDef[T any] struct {
	Type        client.EntityType
	PrimaryFlag string           // positional-name flag, e.g. "title"
	PrimaryAttr string           // its payload key
	PrimarySet  func(*T, string) // writes the positional name onto the VO
	Flags       []FlagDef[T]
	Relations   []Relation
	Label       func(*T) string // display label for pickers and output
	Detail      func(*T) string // distinguishing info shown beside labels
}

EntityDef describes one catalog entity type for the generic commands.

type ExitCoder

type ExitCoder interface {
	error
	ExitCode() int
}

ExitCoder lets subcommands pick their process exit code. Auth failures are 3 so scripts can react without parsing stderr.

type ExitError

type ExitError struct {
	Code int
	Err  error
}

ExitError adapts any error to an exit code.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) ExitCode

func (e *ExitError) ExitCode() int

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type FlagDef

type FlagDef[T any] struct {
	Name     string // flag spelling, e.g. "short-title"
	Attr     string // payload key sent to catalog-api (json tag)
	Usage    string
	Repeated bool // flag may appear multiple times; value is a slice
	Set      func(v *T, vals []string) (any, error)
}

FlagDef binds one CLI property flag to a VO field. Set writes the field directly and returns the wire value for PATCH bodies, so renaming or removing that field in catalog-objects breaks the build here - the schema- drift check the design calls for.

type Relation

type Relation struct {
	Type     string // counterpart entity type name
	WireName string // relation key on the wire, e.g. "publisher"
	Many     bool
}

Relation names one modeled connection to another entity type. WireName is the JSON:API relation tag on the owning VO; Many marks array relations.

Jump to

Keyboard shortcuts

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