report

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package report renders a tokenhound.Report. Render is the only output path and every reporter is a pure function of the canonical Report.

Index

Constants

View Source
const (
	// FormatTerminal is the plain-ASCII human summary.
	FormatTerminal = "terminal"
	// FormatJSON is the canonical JSON Report (docs/schema/report.v1.json).
	FormatJSON = "json"
)

Output formats Render implements.

View Source
const (
	// DefaultWidth is the terminal width assumed when TerminalOptions.Width is 0.
	DefaultWidth = 80
	// DefaultMaxRows is the number of rows shown without --all.
	DefaultMaxRows = 20
)

Terminal defaults.

Variables

View Source
var (
	// ErrUnknownFormat: the format is not one Render implements.
	ErrUnknownFormat = errors.New("report: unknown format")
	// ErrNilReport: Render was given no Report.
	ErrNilReport = errors.New("report: nil report")
	// ErrWrite: the writer failed.
	ErrWrite = errors.New("report: write failed")
)

Errors returned by Render.

Functions

func Formats

func Formats() []string

Formats returns the formats Render implements, in documented order.

func Render

func Render(w io.Writer, format string, r *tokenhound.Report) error

Render writes r to w in format. It is the only output path for a Report, and every reporter is a pure function of r: the same Report always renders the same bytes. Output is ASCII only.

func RenderWith

func RenderWith(w io.Writer, format string, r *tokenhound.Report, opts TerminalOptions) error

RenderWith is Render with the options of the terminal format; the machine formats ignore them. The output is a pure function of r and opts.

Types

type TerminalOptions

type TerminalOptions struct {
	// Width is the terminal width in columns; 0 means 80. Under 80 the rows are
	// stacked as "key: value" lines, like Plain.
	Width int
	// Color adds ANSI colour codes to status words and grade letters. The text is the
	// same with or without them.
	Color bool
	// All shows every row instead of the first MaxRows.
	All bool
	// Quiet prints only the headline sentence.
	Quiet bool
	// Plain stacks every row as "key: value" lines.
	Plain bool
	// MaxRows caps the rows shown without All; 0 means DefaultMaxRows.
	MaxRows int
	// NotScanned lists things the CLI chose not to scan, for example "repo not
	// scanned"; each is added to the meta line. It is a CLI decision the Report cannot
	// derive, so it is not part of the Report.
	NotScanned []string
}

TerminalOptions are the render options of the terminal summary. The CLI decides every one of them (TTY, width, NO_COLOR, --no-color, --plain, --quiet, --all); the reporter reads nothing but the Report and these options. The zero value renders an 80 column table without colour and shows at most 20 rows.

Jump to

Keyboard shortcuts

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