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 ¶
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.
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 ¶
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 ¶
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.