Reviewed-on: #33 Co-authored-by: Natercio Moniz <[email protected]>
This commit was merged in pull request #33.
This commit is contained in:
1 parent
6c989c338c
commit
47f38fce2b
20 files changed
+782
-315
No files matched your search
@@ -0,0 +1,34 @@
|
||||
// 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()
|
||||
}
|
||||
Reference in new issue
Block a user