-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
73 lines (61 loc) · 1.73 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2020-2021 C4 Project
//
// This file is part of c4t.
// Licenced under the MIT licence; see `LICENSE`.
package pretty
import (
"io"
"github.com/c4-project/c4t/internal/helper/iohelp"
)
// Option is the type of options for a pretty-printer.
type Option func(*Printer)
// Options combines the options os into a single option.
func Options(os ...Option) Option {
return func(aw *Printer) {
for _, o := range os {
o(aw)
}
}
}
// WriteTo sets the printer's output to w.
func WriteTo(w io.Writer) Option {
return func(aw *Printer) {
aw.w = iohelp.EnsureWriter(w)
}
}
// ShowOk sets whether the printer should show subjects in the 'ok' category, according to show.
func ShowOk(show bool) Option {
return func(aw *Printer) {
aw.ctx.ShowOk = show
}
}
// ShowCompilers sets whether the printer should show compiler information, according to show.
func ShowCompilers(show bool) Option {
return func(aw *Printer) {
aw.ctx.ShowCompilers = show
}
}
// ShowSubjects sets whether the printer should show subject breakdowns, according to show.
func ShowSubjects(show bool) Option {
return func(aw *Printer) {
aw.ctx.ShowSubjects = show
}
}
// ShowPlanInfo sets whether the printer should show plan metadata, according to show.
func ShowPlanInfo(show bool) Option {
return func(aw *Printer) {
aw.ctx.ShowPlanInfo = show
}
}
// ShowCompilerLogs sets whether the printer should show compiler metadata, according to show.
func ShowCompilerLogs(show bool) Option {
return func(aw *Printer) {
aw.ctx.ShowCompilerLogs = show
}
}
// ShowMutation sets whether the printer should show mutation testing results, according to show.
func ShowMutation(show bool) Option {
return func(aw *Printer) {
aw.ctx.ShowMutation = show
}
}