-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.go
134 lines (101 loc) · 4.71 KB
/
builder.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package flags
import (
"flag"
"time"
)
type Builder struct {
prefix string
docPrefix string
name string
shorthand string
label string
env string
envSeparator string
}
func New(name, label string) Builder {
return Builder{
name: firstUpperCase(name),
label: label,
envSeparator: ",",
}
}
func (b Builder) Shorthand(shorthand string) Builder {
b.shorthand = shorthand
return b
}
func (b Builder) Prefix(prefix string) Builder {
b.prefix = prefix
return b
}
func (b Builder) DocPrefix(docPrefix string) Builder {
b.docPrefix = docPrefix
return b
}
func (b Builder) Env(env string) Builder {
b.env = env
return b
}
func (b Builder) EnvSeparator(envSeparator string) Builder {
b.envSeparator = envSeparator
return b
}
func (b Builder) String(fs *flag.FlagSet, value string, overrides []Override) *string {
return String(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Int(fs *flag.FlagSet, value int, overrides []Override) *int {
return Int(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Int64(fs *flag.FlagSet, value int64, overrides []Override) *int64 {
return Int64(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Uint(fs *flag.FlagSet, value uint, overrides []Override) *uint {
return Uint(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Uint64(fs *flag.FlagSet, value uint64, overrides []Override) *uint64 {
return Uint64(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Float64(fs *flag.FlagSet, value float64, overrides []Override) *float64 {
return Float64(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Float64Slice(fs *flag.FlagSet, value []float64, overrides []Override) *[]float64 {
return Float64Slice(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, b.envSeparator, value, overrides)
}
func (b Builder) Bool(fs *flag.FlagSet, value bool, overrides []Override) *bool {
return Bool(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Duration(fs *flag.FlagSet, value time.Duration, overrides []Override) *time.Duration {
return Duration(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) StringSlice(fs *flag.FlagSet, value []string, overrides []Override) *[]string {
return StringSlice(fs, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, b.envSeparator, value, overrides)
}
func (b Builder) StringVar(fs *flag.FlagSet, output *string, value string, overrides []Override) {
StringVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) IntVar(fs *flag.FlagSet, output *int, value int, overrides []Override) {
IntVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Int64Var(fs *flag.FlagSet, output *int64, value int64, overrides []Override) {
Int64Var(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) UintVar(fs *flag.FlagSet, output *uint, value uint, overrides []Override) {
UintVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Uint64Var(fs *flag.FlagSet, output *uint64, value uint64, overrides []Override) {
Uint64Var(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) Float64Var(fs *flag.FlagSet, output *float64, value float64, overrides []Override) {
Float64Var(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) BoolVar(fs *flag.FlagSet, output *bool, value bool, overrides []Override) {
BoolVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) DurationVar(fs *flag.FlagSet, output *time.Duration, value time.Duration, overrides []Override) {
DurationVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, value, overrides)
}
func (b Builder) StringSliceVar(fs *flag.FlagSet, output *[]string, value []string, overrides []Override) {
StringSliceVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, b.envSeparator, value, overrides)
}
func (b Builder) Float64SliceVar(fs *flag.FlagSet, output *[]float64, value []float64, overrides []Override) {
Float64SliceVar(fs, output, b.prefix, b.docPrefix, b.name, b.shorthand, b.label, b.env, b.envSeparator, value, overrides)
}