Documentation
¶
Overview ¶
Package readable renders API values as plain, labeled text.
Index ¶
- func ChoiceTitle(value string) string
- func DecodeJSONStringBytes(ctx context.Context, out io.Writer, source io.Reader) error
- func EscapeDirectionalControls(text string) string
- func ListTable(headers []string, rows [][]string, width int) (string, bool)
- func Text(text string) string
- func Write(w io.Writer, value gjson.Result) error
- func WriteJSONStream(ctx context.Context, out io.Writer, source io.Reader, ...) error
- func WriteText(out io.Writer, value string) error
- type JSONStreamStorageError
- type StreamEvent
- type StreamPart
- type StreamWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChoiceTitle ¶ added in v1.39.1
ChoiceTitle renders the existing compact label for a command's selected value.
func DecodeJSONStringBytes ¶ added in v1.44.2
DecodeJSONStringBytes decodes escapes from an already validated JSON string. Raw invalid UTF8 bytes retain their identity. Surrogate escapes preserve existing gjson behavior. Readable values separately sanitize invalid bytes.
func EscapeDirectionalControls ¶ added in v1.45.1
EscapeDirectionalControls quotes directional marks and line separators without changing terminal styling. The caller must handle untrusted terminal escapes.
func ListTable ¶ added in v1.39.0
ListTable renders one loaded page. The first column contains complete IDs. A false result requests labeled output when the columns cannot fit safely.
func Text ¶
Text escapes terminal controls and directional marks while preserving ordinary newlines and tabs. It adds no newline and does not redact sensitive content.
func Write ¶
Write renders value in its original field order, without a pager or a table. Strings and array values are complete, including multiline text. Terminal controls are escaped even when w is a redirected output stream.
func WriteJSONStream ¶ added in v1.44.2
func WriteJSONStream(ctx context.Context, out io.Writer, source io.Reader, temporaryFile func() (*os.File, func() error, error)) error
WriteJSONStream renders one already validated JSON document with Write's labels and spacing. Strings and numbers stream in bounded chunks. Unusually large keys use caller-owned private scratch storage, never a rejection limit.
Types ¶
type JSONStreamStorageError ¶ added in v1.44.2
type JSONStreamStorageError struct {
// contains filtered or unexported fields
}
JSONStreamStorageError identifies scratch storage failures without exposing paths.
func (*JSONStreamStorageError) Error ¶ added in v1.44.2
func (e *JSONStreamStorageError) Error() string
func (*JSONStreamStorageError) Unwrap ¶ added in v1.44.2
func (e *JSONStreamStorageError) Unwrap() error
type StreamEvent ¶ added in v1.22.0
type StreamEvent struct {
Parts []StreamPart
Details gjson.Result
}
StreamEvent carries projected text and any accompanying structured details. An empty event represents progress without visible content.
type StreamPart ¶ added in v1.22.0
StreamPart describes one identified text component. A snapshot contains its complete text so far; other parts append a delta. Labels distinguish alternatives.
type StreamWriter ¶ added in v1.22.0
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter emits text immediately and retains only a digest per component. It never consumes an iterator or chooses which API fields to display.
func NewStreamWriter ¶ added in v1.22.0
func NewStreamWriter(out io.Writer) *StreamWriter
func (*StreamWriter) Finish ¶ added in v1.22.0
func (w *StreamWriter) Finish() error
Finish closes partial text before the caller reports completion or an error.
func (*StreamWriter) HasOutput ¶ added in v1.22.0
func (w *StreamWriter) HasOutput() bool
func (*StreamWriter) Write ¶ added in v1.22.0
func (w *StreamWriter) Write(event StreamEvent) error
func (*StreamWriter) WriteValue ¶ added in v1.22.0
func (w *StreamWriter) WriteValue(value gjson.Result) error
WriteValue preserves unfamiliar or non-text content as ordinary labeled data.