displayterminal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(a *recurv1.ActionDetail, jsonFlag, verbose bool) error

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

func FormatAmbiguousError(err error) string

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 Group

func Group(g *recurv1.GroupDetail, jsonFlag bool) error

func HandleAmbiguousError

func HandleAmbiguousError(err error, jsonFlag bool) error

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 JoinNames

func JoinNames(names []string) string

JoinNames concatenates names with ", " separators.

func Plugin

func Plugin(p *recurv1.PluginDetail, jsonFlag, verbose bool) error

func PrintJSON

func PrintJSON(v any) error

PrintJSON marshals v with two-space indent and writes it to stdout with a trailing newline. Returns the marshalling error if any.

func Recurfile

func Recurfile(w *recurv1.RecurfileDetail, jsonFlag bool) error

func SafeID

func SafeID(id string) string

SafeID truncates an ID to at most 8 characters for compact display.

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.

func Trigger

func Trigger(t *recurv1.TriggerDetail, jsonFlag, verbose bool) error

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

Jump to

Keyboard shortcuts

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