Documentation
¶
Overview ¶
Package listview provides lazy terminal list navigation and loaded-page rendering.
Index ¶
- func ContentFits(content string, width, height int) bool
- func RenderLabels(items []gjson.Result, transform transformers.Transformer, ...) (string, error)
- func RenderTable(ctx context.Context, operation string, items []gjson.Result, width int, ...) (string, bool, error)
- func Run(opts Options, fetch func() (Page, error), cancel context.CancelFunc) error
- func ShowPages[P JSONListPage[P]](first func(context.Context) (P, error), itemsToDisplay int64, opts Options, ...) error
- type JSONListPage
- type Model
- type Options
- type Page
- type PaginationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentFits ¶
ContentFits counts the original output's terminal rows, leaving one row for the shell prompt. Hardwrap treats tabs as zero-width controls; terminal output instead advances to the next eight-column tab stop.
func RenderLabels ¶
func RenderLabels(items []gjson.Result, transform transformers.Transformer, opts clioutput.ReadableOptions) (string, error)
RenderLabels preserves complete values independently of table widths.
func RenderTable ¶
func RenderTable(ctx context.Context, operation string, items []gjson.Result, width int, diagnostics bool) (string, bool, error)
RenderTable only presents loaded API items. The caller owns routing, automatic-terminal selection, fetching, cancellation, and fallback output.
func ShowPages ¶
func ShowPages[P JSONListPage[P]](first func(context.Context) (P, error), itemsToDisplay int64, opts Options, cursorField string) error
ShowPages requests pages only when the viewer needs them. The first request receives the same cancelable context as all subsequent SDK requests. cursorField is empty for item-ID cursors, or the SDK's envelope cursor field.
Types ¶
type JSONListPage ¶
type JSONListPage[P any] interface { comparable RawJSON() string GetNextPage() (P, error) }
JSONListPage is implemented by the SDK's explicit API page types.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model owns navigation state and the lifetime of its single fetch worker.
func New ¶
func New(opts Options, fetch func() (Page, error), cancel context.CancelFunc, width, height int) *Model
New constructs the loaded-page event model without taking terminal ownership. The caller must call Finish after its event loop restores the terminal.
type Options ¶
type Options struct {
Context context.Context
Stdout io.Writer
RenderPage func([]gjson.Result, int) (string, error)
RenderPrint func([]gjson.Result) (string, error)
PrintHint func(count, width int) string
Interrupt func(error) error
}
Options supplies presentation and feature policy for the shared viewer. Context and render functions must be non-nil. Stdout must be a terminal file when used by Run; New also permits buffered output for an embedded event loop.
type PaginationError ¶
type PaginationError struct{}
PaginationError is a fixed diagnostic that never includes API cursors or response data.
func (*PaginationError) Error ¶
func (*PaginationError) Error() string