/
options.go
58 lines (47 loc) · 912 Bytes
/
options.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
package tidy
type Option func(*Options)
type Options struct {
SourcePath string
TargetPath string
Pattern string
DryRun bool
DeleteSrc bool
DuplicationAutoReplace bool
}
func newOptions(options ...Option) Options {
opt := Options{}
for _, o := range options {
o(&opt)
}
return opt
}
func SourcePath(src string) Option {
return func(o *Options) {
o.SourcePath = src
}
}
func TargetPath(dst string) Option {
return func(o *Options) {
o.TargetPath = dst
}
}
func Pattern(pattern string) Option {
return func(o *Options) {
o.Pattern = pattern
}
}
func DryRun(d bool) Option {
return func(o *Options) {
o.DryRun = d
}
}
func DeleteSrc(d bool) Option {
return func(o *Options) {
o.DeleteSrc = d
}
}
func DuplicationAutoReplace(d bool) Option {
return func(o *Options) {
o.DuplicationAutoReplace = d
}
}