-
Notifications
You must be signed in to change notification settings - Fork 4
/
helper.go
44 lines (39 loc) · 1.2 KB
/
helper.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
package cmd
import (
"context"
"strings"
"github.com/samber/lo"
"projectforge.dev/projectforge/app/lib/exec"
"projectforge.dev/projectforge/app/module"
"projectforge.dev/projectforge/app/project"
"projectforge.dev/projectforge/app/project/action"
"projectforge.dev/projectforge/app/project/export"
"projectforge.dev/projectforge/app/util"
)
func runToCompletion(ctx context.Context, projectKey string, t action.Type, cfg util.ValueMap) *action.Result {
mSvc, _ := module.NewService(ctx, _flags.ConfigDir, _logger)
pSvc := project.NewService()
eSvc := export.NewService()
xSvc := exec.NewService()
logger := _logger.With("service", "runner")
p := &action.Params{ProjectKey: projectKey, T: t, Cfg: cfg, MSvc: mSvc, PSvc: pSvc, SSvc: nil, XSvc: xSvc, ESvc: eSvc, CLI: true, Logger: logger}
return action.Apply(ctx, p)
}
func extractConfig(args []string) util.ValueMap {
var retArgs []string
retMap := util.ValueMap{}
lo.ForEach(args, func(arg string, _ int) {
l, r := util.StringSplit(arg, '=', true)
l = strings.TrimSpace(l)
r = strings.TrimSpace(r)
if r == "" {
retArgs = append(retArgs, l)
} else {
retMap[l] = r
}
})
if len(retArgs) > 0 {
retMap["cmds"] = retArgs
}
return retMap
}