Documentation
¶
Overview ¶
Package display formats domain values and gRPC errors for terminal output. It belongs in infra because rendering is an I/O concern: it writes to stdout/stderr, formats for the user's terminal, and emits JSON for scripting. Callers (CLI commands) pass in domain or proto values and let display turn them into human-readable text.
Index ¶
- func Action(a *recurv1.ActionDetail, jsonFlag, verbose bool) error
- func EmitAmbiguousJSON(ambiguous *recurv1.AmbiguousEntity) error
- func EntityStatus(s recurv1.EntityStatus) string
- func ExtractAmbiguousDetail(err error) *recurv1.AmbiguousEntity
- func FormatAmbiguousError(err error) string
- func FormatCandidates(ambiguous *recurv1.AmbiguousEntity) string
- func Group(g *recurv1.GroupDetail, jsonFlag bool) error
- func HandleAmbiguousError(err error, jsonFlag bool) error
- func InspectEntityResponse(resp *recurv1.InspectEntityResponse, jsonFlag, verbose bool) error
- func JoinNames(names []string) string
- func Plugin(p *recurv1.PluginDetail, jsonFlag, verbose bool) error
- func PrintJSON(v any) error
- func Recurfile(w *recurv1.RecurfileDetail, jsonFlag bool) error
- func SafeID(id string) string
- func StatusLabel(s recurv1.EntityStatus) string
- func Trigger(t *recurv1.TriggerDetail, jsonFlag, verbose bool) error
- type AmbiguousError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitAmbiguousJSON ¶
func EmitAmbiguousJSON(ambiguous *recurv1.AmbiguousEntity) error
EmitAmbiguousJSON writes the structured ambiguity payload to stdout.
func EntityStatus ¶
func EntityStatus(s recurv1.EntityStatus) string
EntityStatus formats a proto EntityStatus enum as a lowercase word suitable for tabular display.
func ExtractAmbiguousDetail ¶
func ExtractAmbiguousDetail(err error) *recurv1.AmbiguousEntity
ExtractAmbiguousDetail returns the AmbiguousEntity detail from a gRPC error, or nil if none is present.
func FormatAmbiguousError ¶
FormatAmbiguousError extracts an AmbiguousEntity detail from a gRPC error and formats it for display. Returns an empty string if the error does not contain an AmbiguousEntity detail.
func FormatCandidates ¶
func FormatCandidates(ambiguous *recurv1.AmbiguousEntity) string
FormatCandidates builds the human-readable ambiguity message. Group and recurfile columns appear only when candidates share a (type, name) pair.
func HandleAmbiguousError ¶
HandleAmbiguousError checks for ambiguity and returns the appropriate error. When jsonFlag is true and the error is ambiguous, it emits structured JSON to stdout and returns an AmbiguousError. When jsonFlag is false, it returns a formatted AmbiguousError for stderr. Returns nil if the error is not ambiguous.
func InspectEntityResponse ¶
func InspectEntityResponse(resp *recurv1.InspectEntityResponse, jsonFlag, verbose bool) error
InspectEntityResponse dispatches to the correct per-entity display function based on resp.EntityType. Returns an error for unknown types.
func PrintJSON ¶
PrintJSON marshals v with two-space indent and writes it to stdout with a trailing newline. Returns the marshalling error if any.
func StatusLabel ¶
func StatusLabel(s recurv1.EntityStatus) string
StatusLabel returns a parenthesized suffix for non-active statuses, or an empty string when active. Used to annotate list rows.
Types ¶
type AmbiguousError ¶
type AmbiguousError struct {
Message string
}
AmbiguousError signals that the user gave an identifier that matched multiple entities. The CLI maps this to exit code 2.
func (*AmbiguousError) Error ¶
func (e *AmbiguousError) Error() string