forked from hofstadter-io/hof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
from-args.go
60 lines (50 loc) · 1.21 KB
/
from-args.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
package cuetils
import (
"cuelang.org/go/cue/load"
"github.com/hofstadter-io/hof/cmd/hof/flags"
)
// CueRuntimeFromArgs builds up a CueRuntime
// by processing the args passed in
func CueRuntimeFromEntrypoints(entrypoints []string) (crt *CueRuntime, err error) {
crt = &CueRuntime{
Entrypoints: entrypoints,
CueConfig: &load.Config{
ModuleRoot: "",
Module: "",
Package: "",
Dir: "",
BuildTags: []string{},
Tests: false,
Tools: false,
DataFiles: false,
Overlay: map[string]load.Source{},
},
}
err = crt.Load()
return crt, err
}
// CueRuntimeFromArgsAndFlags builds up a CueRuntime
// by processing the args passed in AND the current flag values
func CueRuntimeFromEntrypointsAndFlags(entrypoints []string) (crt *CueRuntime, err error) {
cfg := &load.Config{
ModuleRoot: "",
Module: "",
Package: "",
Dir: "",
BuildTags: []string{},
Tests: false,
Tools: false,
DataFiles: false,
Overlay: map[string]load.Source{},
}
// package?
if flags.RootPflags.Package != "" {
cfg.Package = flags.RootPflags.Package
}
crt = &CueRuntime{
Entrypoints: entrypoints,
CueConfig: cfg,
}
err = crt.Load()
return crt, err
}