render

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText = "text"
	FormatJSON = "json"
	FormatTOON = "toon"
)

FormatText, FormatJSON, and FormatTOON are the canonical format names used as registry keys and CLI flag values. Keep this list in sync with registry.

Variables

This section is empty.

Functions

func Names added in v0.3.0

func Names() []string

Names returns the registered format names in stable (sorted) order. Used for help text and error messages.

Types

type Context

type Context struct {
	Color     bool
	OSC8      bool
	LatencyMs int
	// ShowStats toggles the compact stats footer ("Nms · ● Npt · N remaining").
	// Off by default: the line is noise for the common case and always visible
	// via `gh prs --stats`. Only consulted by the text formatter; machine
	// formats (json, toon) always emit RateLimit as a structured field.
	ShowStats bool
	// FilterLabel is a short human-readable summary of the active filters for
	// display in the repo header (e.g. "@alice, @bob"). An empty string means
	// "no override" — the header falls back to showing the viewer's real login.
	// Populated by filter.Set.Label() in the CLI layer; the render package has
	// no knowledge of the filter package.
	FilterLabel string
	// AuthorOrder is the ordered list of author logins from the --author flags.
	// When len > 1, the text formatter groups PRs into per-author sections.
	// The sentinel "@me" is resolved to repo.ViewerLogin at render time.
	// Single-author and no-author invocations (len <= 1) use the flat layout.
	AuthorOrder []string
}

type Formatter

type Formatter interface {
	Format(repo *model.Repo, ctx Context) (string, error)
}

Formatter renders a fetched repo into its target output form. Implementations return (output, nil) on success. A non-nil error indicates an encoder failure the caller must surface — the output string is then undefined and must not be written to stdout.

func Lookup added in v0.3.0

func Lookup(name string) (Formatter, bool)

Lookup returns the Formatter for the given canonical name and whether it is registered.

type JSON

type JSON struct{}

func (JSON) Format

func (JSON) Format(repo *model.Repo, ctx Context) (string, error)

type TOON added in v0.3.0

type TOON struct{}

func (TOON) Format added in v0.3.0

func (TOON) Format(repo *model.Repo, ctx Context) (string, error)

type Text

type Text struct{}

func (Text) Format

func (Text) Format(repo *model.Repo, ctx Context) (string, error)

Jump to

Keyboard shortcuts

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