-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.go
37 lines (33 loc) · 893 Bytes
/
handlers.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
package main
import (
"io/ioutil"
"github.com/peterfraedrich/mason/build"
"github.com/peterfraedrich/mason/survey"
"github.com/thatisuday/commando"
)
func surveyHandler(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) {
outForm := flags["output"].Value.(string)
res, err := survey.DoSurvey(flags["packages"].Value.(bool))
if err != nil {
handleError(err, "surveyHandler.DoSurvey")
return
}
err = survey.WriteOutput(res, outForm)
if err != nil {
handleError(err, "surveyHandler.WriteOutput")
return
}
}
func buildHandler(args map[string]commando.ArgValue, flags map[string]commando.FlagValue) {
bpFile := flags["blueprint"].Value.(string)
bp, err := ioutil.ReadFile(bpFile)
if err != nil {
handleError(err, "buildHandler.ReadFile")
return
}
err = build.GoBuild(bp)
if err != nil {
handleError(err, "buildHandler.GoBuild")
return
}
}