/
custom.go
48 lines (40 loc) · 880 Bytes
/
custom.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
package installer
import (
"github.com/wx13/genesis"
)
// Custom is a type of genesis.Doer. It is a wrapper around another
// Doer which allows for custom Status/Do/Undo functions.
type Custom struct {
Task genesis.Doer
S func() (genesis.Status, error)
D func() (bool, error)
U func() (bool, error)
I func() string
F func() []string
}
func NewCustom(task genesis.Doer) *Custom {
custom := Custom{
Task: task,
S: task.Status,
D: task.Do,
U: task.Undo,
I: task.ID,
F: task.Files,
}
return &custom
}
func (custom Custom) Status() (genesis.Status, error) {
return custom.S()
}
func (custom Custom) Do() (bool, error) {
return custom.D()
}
func (custom Custom) Undo() (bool, error) {
return custom.U()
}
func (custom Custom) ID() string {
return custom.I()
}
func (custom Custom) Files() []string {
return custom.F()
}