Files
any2anexoj/internal/writing/table/printer.go
natercio 47f38fce2b
Badges / coveralls (push) Successful in 1m1s
Implement HTML writer (#33)
Reviewed-on: #33
Co-authored-by: Natercio Moniz <[email protected]>
2026-10-05 16:25:21 +01:00

35 lines
1.0 KiB
Go

// Package table renders an internal.AggregatorWriter as the human-readable
// Anexo J report table for the terminal. The shared table definition it (and
// the html package) renders from lives in internal/writing/internal/tabledef.
package table
import (
"io"
"github.com/nmoniz/any2anexoj/internal"
"github.com/nmoniz/any2anexoj/internal/writing/internal/tabledef"
)
// Printer writes a simple, human readable, table to the provided io.Writer
// for the report items in an AggregatorWriter. Each Render call builds a
// fresh table from the aggregator, so invoking it repeatedly on the same
// instance never duplicates rows.
type Printer struct {
output io.Writer
translator tabledef.Translator
}
func NewPrinter(w io.Writer, tr tabledef.Translator) *Printer {
return &Printer{
output: w,
translator: tr,
}
}
// Render writes the terminal table for aw to the configured output.
func (pp *Printer) Render(aw *internal.AggregatorWriter) {
t := tabledef.Build(pp.translator, aw)
t.SetOutputMirror(pp.output)
t.Render()
}