Documentation
¶
Overview ¶
Package tally parses fo's tally input format — a count→label distribution that renders as a Leaderboard view. The format is the minimal shape needed to feed arbitrary tallies (e.g. `sort | uniq -c` output) into fo without going through SARIF (whose parser computes scores internally and would discard caller-supplied counts).
Format:
# fo:tally [tool=<name>] <count> <label> <count> <label> ...
One header line, then count/label rows. Leading whitespace is tolerated on data rows so `sort | uniq -c` output (which right-aligns counts) is accepted verbatim. Lines beginning with `#` after the header are comments and ignored. Blank lines are ignored.
Index ¶
Constants ¶
const HeaderPrefix = "# fo:tally"
HeaderPrefix is the sentinel that marks tally input. Used by fo's stdin sniffer to route tally streams away from SARIF/test-json parsing.
Variables ¶
var ErrMalformedRow = errors.New("tally: malformed row")
ErrMalformedRow wraps row-level shape and parse failures. Wrapped via fmt.Errorf("...: %w", ErrMalformedRow) at call sites — sentinel keeps err113 happy and lets callers errors.Is on a single root.
var ErrNoHeader = errors.New("tally: missing '# fo:tally' header")
ErrNoHeader is returned when input lacks the tally header line.
var ErrNoRows = errors.New("tally: no data rows")
ErrNoRows is returned when the header is present but no data rows followed.
Functions ¶
Types ¶
type Tally ¶
Tally is a parsed tally stream.
func Parse ¶
Parse reads tally input from r and returns the parsed Tally. Malformed data lines (no count, non-numeric count) cause a parse error pinned to the line number; tolerant to leading whitespace and comment/blank lines.
func (Tally) RenderLLM ¶
RenderLLM emits a terse plain-text ranking. Used when fo's output mode is llm — bar charts are useless to AI consumers; a sorted "label\tcount" listing is the densest faithful form.
func (Tally) ToLeaderboard ¶
func (t Tally) ToLeaderboard() view.Leaderboard
ToLeaderboard builds a view.Leaderboard from t. Rows are emitted in input order; Total is the sum of all values (used by the renderer to scale bars).