2021-04-04 03:42:05 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2021-05-23 14:23:35 +00:00
|
|
|
"github.com/qiniu/goc/v2/pkg/build"
|
2021-04-04 03:42:05 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var buildCmd = &cobra.Command{
|
|
|
|
Use: "build",
|
2021-05-23 14:23:35 +00:00
|
|
|
Run: buildAction,
|
2021-04-19 02:18:37 +00:00
|
|
|
|
|
|
|
DisableFlagParsing: true, // build 命令需要用原生 go 的方式处理 flags
|
2021-04-04 03:42:05 +00:00
|
|
|
}
|
|
|
|
|
2021-09-02 06:36:41 +00:00
|
|
|
var (
|
|
|
|
gocmode string
|
|
|
|
gochost string
|
|
|
|
)
|
|
|
|
|
2021-04-04 03:42:05 +00:00
|
|
|
func init() {
|
2021-09-02 06:36:41 +00:00
|
|
|
buildCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
|
|
|
|
buildCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
|
2021-04-04 03:42:05 +00:00
|
|
|
rootCmd.AddCommand(buildCmd)
|
|
|
|
}
|
2021-04-19 02:18:37 +00:00
|
|
|
|
2021-05-23 14:23:35 +00:00
|
|
|
func buildAction(cmd *cobra.Command, args []string) {
|
2021-09-02 06:36:41 +00:00
|
|
|
|
|
|
|
sets := build.CustomParseCmdAndArgs(cmd, args)
|
|
|
|
|
|
|
|
b := build.NewBuild(
|
|
|
|
build.WithHost(gochost),
|
|
|
|
build.WithMode(gocmode),
|
|
|
|
build.WithFlagSets(sets),
|
|
|
|
build.WithArgs(args),
|
|
|
|
build.WithBuild(),
|
|
|
|
build.WithDebug(globalDebug),
|
|
|
|
)
|
2021-05-23 14:23:35 +00:00
|
|
|
b.Build()
|
2021-09-02 06:36:41 +00:00
|
|
|
|
2021-04-19 02:18:37 +00:00
|
|
|
}
|