Generate check / check-changes (pull_request) Successful in 2s
Generate check / verify-generate (pull_request) Skipped
Quality / check-changes (pull_request) Successful in 2s
Quality / static-checks (pull_request) Failing after 13s
Quality / run-tests (pull_request) Failing after 54s
35 lines
1.0 KiB
Go
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()
|
|
}
|