view

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Materialize

func Materialize[T any](data []T, mode Mode) ([]any, error)

Types

type Format

type Format string
const (
	FormatJSON  Format = "json"
	FormatTable Format = "table"
	FormatCSV   Format = "csv"
)

func NormalizeFormat

func NormalizeFormat(format string) (Format, error)

type Mode

type Mode string
const (
	ModeSummary  Mode = "summary"
	ModeExpanded Mode = "expanded"
)

func NormalizeMode

func NormalizeMode(mode string) (Mode, error)

type RendererFactory

type RendererFactory func() renderers.Renderer

type Summarizable

type Summarizable interface {
	Summary() (any, error)
}

type Transformable

type Transformable interface {
	Transform() (any, error)
}

type View

type View[T any] struct {
	Format Format
	Mode   Mode
	Data   []T
	// contains filtered or unexported fields
}

func New

func New[T any](format, mode string, data []T, opts ...ViewOpts[T]) (*View[T], error)

func (*View[T]) Render

func (v *View[T]) Render(w io.Writer) error

type ViewOpts

type ViewOpts[T any] func(*View[T]) error

func SingleElemAndCompose

func SingleElemAndCompose[T any]() ViewOpts[T]

func WithViewRender

func WithViewRender[T any](vr *ViewRender) ViewOpts[T]

type ViewRender

type ViewRender struct {
	// contains filtered or unexported fields
}

func NewViewRender

func NewViewRender(opts ...ViewRenderOpt) (*ViewRender, error)

func (*ViewRender) GetRenderer

func (r *ViewRender) GetRenderer(format Format) (renderers.Renderer, error)

func (*ViewRender) RegisterRenderer

func (r *ViewRender) RegisterRenderer(format Format, factory RendererFactory) error

func (*ViewRender) Render

func (r *ViewRender) Render(format Format, w io.Writer, items []any, opts ...renderers.RendererOptFunc) error

type ViewRenderOpt

type ViewRenderOpt func(*ViewRender) error

func WithCsvRender

func WithCsvRender() ViewRenderOpt

func WithJsonRender

func WithJsonRender() ViewRenderOpt

func WithTableRender

func WithTableRender() ViewRenderOpt

Directories

Path Synopsis
csv

Jump to

Keyboard shortcuts

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