1package report
2
3import (
4	"fmt"
5
6	c "github.com/future-architect/vuls/config"
7	"github.com/future-architect/vuls/models"
8)
9
10// StdoutWriter write to stdout
11type StdoutWriter struct{}
12
13// WriteScanSummary prints Scan summary at the end of scan
14func (w StdoutWriter) WriteScanSummary(rs ...models.ScanResult) {
15	fmt.Printf("\n\n")
16	fmt.Println("Scan Summary")
17	fmt.Println("================")
18	fmt.Printf("%s\n", formatScanSummary(rs...))
19}
20
21func (w StdoutWriter) Write(rs ...models.ScanResult) error {
22	if c.Conf.FormatOneLineText {
23		fmt.Print("\n\n")
24		fmt.Println("One Line Summary")
25		fmt.Println("================")
26		fmt.Println(formatOneLineSummary(rs...))
27		fmt.Print("\n")
28	}
29
30	if c.Conf.FormatList || c.Conf.FormatCsvList {
31		for _, r := range rs {
32			fmt.Println(formatList(r))
33		}
34	}
35
36	if c.Conf.FormatFullText {
37		for _, r := range rs {
38			fmt.Println(formatFullPlainText(r))
39		}
40	}
41	return nil
42}
43