-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoption.go
70 lines (57 loc) · 1.47 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
package inkscape
// Option define method to modify config options
type Option func(o *Options)
// Options of configuration package
type Options struct {
// command name, by default is "inkscape"
// but it may depends on system setup
// therefore allow user to override if needed
commandName string
// maximum retry attempt
maxRetry int
// maximum command queue size
commandQueueLength int
// set verbosity
verbose bool
// allow to suppress warning
suppressWarning bool
}
// CommandName customize inkscape executable name
// this may vary based on system setup / configuration
func CommandName(commandName string) Option {
return func(o *Options) {
o.commandName = commandName
}
}
// MaxRetry override maximum retry attempt when running
// inkscape background process
func MaxRetry(retry int) Option {
return func(o *Options) {
o.maxRetry = retry
}
}
// CommandQueueLength override maximum command queue size
func CommandQueueLength(length int) Option {
return func(o *Options) {
o.commandQueueLength = length
}
}
// SuppressWarning override default suppress warning option, that are enabled
func SuppressWarning(suppress bool) Option {
return func(o *Options) {
o.suppressWarning = suppress
}
}
// Verbose override log verbosity
// useful for debugging
func Verbose(verbose bool) Option {
return func(o *Options) {
o.verbose = verbose
}
}
func mergeOptions(dest Options, opts ...Option) Options {
for _, opt := range opts {
opt(&dest)
}
return dest
}