Files
vuls/reporter/stdout.go
MaineK00n 4e486dae1d style: fix typo (#1592)
* style: fix typo

* style: add comment
2023-02-22 15:59:47 +09:00

49 lines
957 B
Go

package reporter
import (
"fmt"
"github.com/future-architect/vuls/models"
)
// StdoutWriter write to stdout
type StdoutWriter struct {
FormatFullText bool
FormatOneLineText bool
FormatList bool
}
//TODO support -format-jSON
// WriteScanSummary prints Scan summary at the end of scan
func (w StdoutWriter) WriteScanSummary(rs ...models.ScanResult) {
fmt.Printf("\n\n")
fmt.Println("Scan Summary")
fmt.Println("================")
fmt.Printf("%s\n", formatScanSummary(rs...))
}
// Write results to stdout
func (w StdoutWriter) Write(rs ...models.ScanResult) error {
if w.FormatOneLineText {
fmt.Print("\n\n")
fmt.Println("One Line Summary")
fmt.Println("================")
fmt.Println(formatOneLineSummary(rs...))
fmt.Print("\n")
}
if w.FormatList {
for _, r := range rs {
fmt.Println(formatList(r))
}
}
if w.FormatFullText {
for _, r := range rs {
fmt.Println(formatFullPlainText(r))
}
}
return nil
}