/
option.go
53 lines (46 loc) · 1.42 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
package mconf
// IndentOption returns a write option that sets the given indent.
func IndentOption(indent string) ReadWriteOption {
return ReadWriteOption{
Key: OptionIndent,
Value: indent,
}
}
// PrettyPrintOption returns an option that enables or disables pretty printing.
func PrettyPrintOption(enabled bool) ReadWriteOption {
return ReadWriteOption{
Key: OptionPrettyPrint,
Value: enabled,
}
}
// ColouriseOption returns an option that enables or disables colourised output.
func ColouriseOption(enabled bool) ReadWriteOption {
return ReadWriteOption{
Key: OptionColourise,
Value: enabled,
}
}
// EscapeHTMLOption returns an option that enables or disables HTML escaping.
func EscapeHTMLOption(enabled bool) ReadWriteOption {
return ReadWriteOption{
Key: OptionEscapeHTML,
Value: enabled,
}
}
// OptionKey is a defined type for keys within a ReadWriteOption.
type OptionKey string
const (
// OptionIndent is the key used with IndentOption.
OptionIndent OptionKey = "indent"
// OptionPrettyPrint is the key used with PrettyPrintOption.
OptionPrettyPrint OptionKey = "prettyPrint"
// OptionColourise is the key used with ColouriseOption.
OptionColourise OptionKey = "colourise"
// OptionEscapeHTML is the key used with EscapeHTMLOption.
OptionEscapeHTML OptionKey = "escapeHtml"
)
// ReadWriteOption is an option to be used when writing.
type ReadWriteOption struct {
Key OptionKey
Value interface{}
}