forked from verless/verless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.go
More file actions
45 lines (36 loc) · 1.02 KB
/
build.go
File metadata and controls
45 lines (36 loc) · 1.02 KB
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
package cli
import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/verless/verless/config"
"github.com/verless/verless/core"
)
// newBuildCmd creates the `verless build` command.
func newBuildCmd() *cobra.Command {
var (
options core.BuildOptions
)
buildCmd := cobra.Command{
Use: "build PROJECT",
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := config.FromFile(args[0], config.Filename)
if err != nil {
return err
}
errs := core.RunBuild(args[0], options, cfg)
if len(errs) == 1 {
return errs[0]
} else if len(errs) > 1 {
return errors.Errorf("several errors occurred while building: %v", errs)
}
return nil
},
Args: cobra.ExactArgs(1),
}
buildCmd.Flags().StringVarP(&options.OutputDir, "output", "o",
"", `specify an output directory`)
// Overwrite should not have a shorthand to avoid accidental usage.
buildCmd.Flags().BoolVar(&options.Overwrite, "overwrite",
false, `allows overwriting an existing output directory`)
return &buildCmd
}