-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
43 lines (37 loc) · 881 Bytes
/
config.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
package stackparse
// Config holds all configuration options for the parser
type Config struct {
Colorize bool
Simple bool
Theme *Theme
}
// Option is a function type for setting configuration options
type Option func(*Config)
// NewConfig creates a new configuration with default values
//
// Mostly used internally but exposed for some edge cases
func NewConfig() *Config {
return &Config{
Colorize: true,
Simple: true,
Theme: DefaultTheme(),
}
}
// WithColor enables or disables colorized output
func WithColor(enabled bool) Option {
return func(c *Config) {
c.Colorize = enabled
}
}
// WithSimple enables or disables simplified output
func WithSimple(enabled bool) Option {
return func(c *Config) {
c.Simple = enabled
}
}
// WithTheme sets a custom theme
func WithTheme(theme *Theme) Option {
return func(c *Config) {
c.Theme = theme
}
}