Adding magic to detect leading seperators

This commit is contained in:
Mike Farah
2021-07-15 11:34:49 +10:00
parent 5c0a5bd9d3
commit d74bb8e28d
8 changed files with 124 additions and 6 deletions
+8
View File
@@ -11,6 +11,7 @@ import (
type Printer interface {
PrintResults(matchingNodes *list.List) error
PrintedAnything() bool
SetPrintLeadingSeperator(bool)
}
type resultsPrinter struct {
@@ -40,6 +41,13 @@ func NewPrinter(writer io.Writer, outputToJSON bool, unwrapScalar bool, colorsEn
}
}
func (p *resultsPrinter) SetPrintLeadingSeperator(printLeadingSeperator bool) {
if printLeadingSeperator {
p.firstTimePrinting = false
p.previousFileIndex = -1
}
}
func (p *resultsPrinter) PrintedAnything() bool {
return p.printedMatches
}