generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
internal-traverse-defs.go
120 lines (95 loc) · 2.51 KB
/
internal-traverse-defs.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
package age
import (
"io/fs"
"github.com/snivilised/agenor/core"
"github.com/snivilised/agenor/internal/enclave"
"github.com/snivilised/agenor/internal/kernel"
"github.com/snivilised/agenor/internal/opts"
"github.com/snivilised/agenor/internal/third/lo"
"github.com/snivilised/agenor/pref"
)
type optionHarvest struct {
o *pref.Options
binder *opts.Binder
loaded *opts.LoadInfo
}
func (a *optionHarvest) Options() *pref.Options {
return a.afterwards(lo.TernaryF(a.loaded != nil,
func() *pref.Options {
return a.loaded.O
},
func() *pref.Options {
return a.o
},
))
}
func (a *optionHarvest) Binder() *opts.Binder {
return a.binder
}
func (a *optionHarvest) Loaded() *opts.LoadInfo {
return a.loaded
}
func (a *optionHarvest) afterwards(o *pref.Options) *pref.Options {
if o.Behaviours.Cascade.NoRecurse {
o.Behaviours.Cascade.Depth = 1
}
if o.Concurrency.Input.Size == 0 {
o.Concurrency.Input.Size = o.Concurrency.NoW
}
if o.Concurrency.Output.On != nil {
if o.Concurrency.Output.Size == 0 {
o.Concurrency.Output.Size = o.Concurrency.NoW
}
}
return o
}
// optionsBuilder
type optionsBuilder interface {
build(ext extent) (enclave.OptionHarvest, error)
}
type optionBuilder func(ext extent) (enclave.OptionHarvest, error)
func (fn optionBuilder) build(ext extent) (enclave.OptionHarvest, error) {
return fn(ext)
}
type pluginsBuilder interface {
build(o *pref.Options,
ext extent,
artefacts *kernel.Artefacts,
others ...enclave.Plugin,
) ([]enclave.Plugin, error)
}
type activated func(*pref.Options,
extent,
*kernel.Artefacts,
...enclave.Plugin,
) ([]enclave.Plugin, error)
func (fn activated) build(o *pref.Options,
ext extent,
artefacts *kernel.Artefacts,
others ...enclave.Plugin,
) ([]enclave.Plugin, error) {
return fn(o, ext, artefacts, others...)
}
type fsBuilder interface {
build(path string) fs.FS
}
type filesystem func(path string) fs.FS
func (fn filesystem) build(path string) fs.FS {
return fn(path)
}
type extentBuilder interface {
build(forest *core.Forest) extent
}
type extension func(forest *core.Forest) extent
func (fn extension) build(forest *core.Forest) extent {
return fn(forest)
}
type scaffoldBuilder interface {
build(addons ...Addon) (scaffold, error)
}
type scaffolding func(addons ...Addon) (scaffold, error)
// build creates a scaffold using the provided addons for configuration.
// The addons parameter allows for customisation of the scaffolding process.
func (fn scaffolding) build(addons ...Addon) (scaffold, error) {
return fn(addons...)
}