Documentation
¶
Overview ¶
Package listview provides lazy terminal list navigation and loaded-page rendering.
Index ¶
- Constants
- func RenderLabels(items []gjson.Result, transform transformers.Transformer, ...) (string, error)
- func RenderRecordTable(ctx context.Context, operation string, items []gjson.Result, width int, ...) (string, bool, 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
- type Model
- type Options
- type Page
- type PaginationError
- type Style
Constants ¶
const ControlsHelp = "" /* 227-byte string literal not displayed */
ControlsHelp describes the shared terminal interaction in command help.
Variables ¶
This section is empty.
Functions ¶
func RenderLabels ¶
func RenderLabels(items []gjson.Result, transform transformers.Transformer, opts clioutput.ReadableOptions) (string, error)
RenderLabels preserves complete values independently of table widths.
func RenderRecordTable ¶ added in v1.51.4
func RenderRecordTable(ctx context.Context, operation string, items []gjson.Result, width int, style Style) (string, bool, error)
RenderRecordTable presents a caller-verified list, including handwritten lists without generated operation metadata. Navigation has its own footer.
func RenderTable ¶
func RenderTable(ctx context.Context, operation string, items []gjson.Result, width int, diagnostics bool, style Style) (string, bool, error)
RenderTable only presents loaded API items. The caller owns routing, automatic-terminal selection, fetching, cancellation, and fallback output.
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 {
PrintOnly bool // write all pages to scrollback without reading keys
Context context.Context
Stdout io.Writer
Style Style
RenderPage func([]gjson.Result, int) (string, error)
Interrupt func(error) error
// Record navigation renders a compact table with a pinned header. If the
// data or terminal width needs labels, it renders one complete item.
RenderTable func([]gjson.Result, int) (string, bool, error)
Singular, Plural string
Hint string
RenderRecordLabels func(item gjson.Result, full bool) (string, error)
// The caller cancels Context on process signals and retains their exit status.
CallerHandlesSignals bool
}
Options supplies presentation and feature policy for the shared viewer. Every viewer requires Context, RenderTable, RenderRecordLabels and RenderPage. RenderPage formats static output and received pages after a failure. Run requires a terminal file for Stdout. New permits buffered output for an embedded event loop.
type Page ¶
type Page struct {
Items []gjson.Result
More bool
Notice string // optional catalog guidance, including a source-specific empty result
FullLabels bool // an ambiguous source page needs the complete original records
Total int // known catalog count, when the source provides one
}
Page contains loaded records and whether another page can be requested.
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
type Style ¶ added in v1.43.2
type Style struct {
// contains filtered or unexported fields
}
Style decorates resource labels and list controls after layout. Its zero value preserves plain output.
func NewFieldStyle ¶ added in v1.51.4
func NewFieldStyle(profile colorprofile.Profile, hint string) Style
NewFieldStyle uses the terminal's foreground when its background is unknown.
func NewStyle ¶ added in v1.43.2
func NewStyle(profile colorprofile.Profile, dark bool) Style
NewStyle uses the same normal-weight blue and secondary colors as command help.
func (Style) Label ¶ added in v1.51.4
Label applies the command-help accent to a field label or table header.