-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
59 lines (48 loc) · 998 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
59
package fmt
import (
"github.com/MontFerret/fmt/internal/core"
)
type (
Options = core.Options
CaseMode = core.CaseMode
Option func(opts *Options)
)
const (
CaseModeIgnore = core.CaseModeIgnore
CaseModeUpper = core.CaseModeUpper
CaseModeLower = core.CaseModeLower
)
func DefaultOptions() *Options {
return &Options{
PrintWidth: 80, // Characters
TabWidth: 4, // Spaces
SingleQuote: false,
BracketSpacing: true,
CaseMode: CaseModeUpper,
}
}
func WithPrintWidth(size uint64) Option {
return func(opts *Options) {
opts.PrintWidth = size
}
}
func WithTabWidth(size uint64) Option {
return func(opts *Options) {
opts.TabWidth = size
}
}
func WithSingleQuote(val bool) Option {
return func(opts *Options) {
opts.SingleQuote = val
}
}
func WithBracketSpacing(val bool) Option {
return func(opts *Options) {
opts.BracketSpacing = val
}
}
func WithCaseMode(mode CaseMode) Option {
return func(opts *Options) {
opts.CaseMode = mode
}
}