-
Notifications
You must be signed in to change notification settings - Fork 2
/
flipper.go
49 lines (40 loc) · 820 Bytes
/
flipper.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
package toggle
import "github.com/xchapter7x/goutil"
func NewTgl() *Tgl {
return new(Tgl)
}
type Tgl struct {
flagName string
onFeature interface{}
offFeature interface{}
args []interface{}
returnValues []interface{}
}
func (s *Tgl) Flag(name string) *Tgl {
s.flagName = name
return s
}
func (s *Tgl) Off(feature interface{}) *Tgl {
s.offFeature = feature
return s
}
func (s *Tgl) On(feature interface{}) *Tgl {
s.onFeature = feature
return s
}
func (s *Tgl) Args(args ...interface{}) *Tgl {
s.args = args
return s
}
func (s *Tgl) Returns(vals ...interface{}) *Tgl {
s.returnValues = vals
return s
}
func (s *Tgl) Run() (res []interface{}, err error) {
res = Flip(s.flagName,
s.offFeature,
s.onFeature,
s.args...)
err = goutil.UnpackArray(res, s.returnValues)
return
}